]> git.lizzy.rs Git - cheatdb.git/commitdiff
Add website and donation support v1.15.0
authorrubenwardy <rw@rubenwardy.com>
Mon, 1 Jul 2019 23:45:04 +0000 (00:45 +0100)
committerrubenwardy <rw@rubenwardy.com>
Mon, 1 Jul 2019 23:45:16 +0000 (00:45 +0100)
app/flatpages/policy_and_guidance.md
app/models.py
app/templates/packages/view.html
app/templates/users/user_profile_page.html
app/views/users/users.py
migrations/versions/d6ae9682c45f_.py [new file with mode: 0644]

index 16de1db618ce0d350d746c08482f423807229a35..0fe110d78052f11cae6e227955117683fe616b61 100644 (file)
@@ -125,15 +125,15 @@ Public domain is not a valid license in many countries, please use CC0 or MIT in
 
 ## 5. Promotions and Advertisements (inc. asking for donations)
 
-Any information other than the long description - including screenshots - must
-not contain any promotions or advertisements. This includes asking for donations,
-promoting online shops, or linking to personal websites and social media.
+You may note place any promotions or advertisements in any meta data including
+screensthos. This includes asking for donations, promoting online shops,
+or linking to personal websites and social media. Please instead use the
+fields provided on your user profile page to place links to websites and
+donation pages.
 
 ContentDB is for the community. We may remove any promotions if we feel that
 they're inappropriate.
 
-Paid promotions are not allowed at all, anywhere.
-
 
 ## 6. Reporting Violations
 
index cecf7658e4aba14a80138676d484a9d565687ac2..583c92a9ce0a6cf8c4863b89242558dbd9d7a144 100644 (file)
@@ -129,6 +129,10 @@ class User(db.Model, UserMixin):
        active        = db.Column("is_active", db.Boolean, nullable=False, server_default="0")
        display_name  = db.Column(db.String(100), nullable=False, server_default="")
 
+       # Links
+       website_url   = db.Column(db.String(255), nullable=True, default=None)
+       donate_url    = db.Column(db.String(255), nullable=True, default=None)
+
        # Content
        notifications = db.relationship("Notification", primaryjoin="User.id==Notification.user_id")
 
index b725dbead2c407f5e561f4f982378960b66203d5..8216c7129507df67c8fa7f171ea9db4c07d2cdfd 100644 (file)
                                </table>
                        </div>
 
+                       {% if package.author.donate_url %}
+                               <div class="alert alert-secondary">
+                                       Like {{ package.author.display_name }}'s work?
+                                       <a href="{{ package.author.donate_url }}" rel="nofollow">Donate now!</a>
+                               </div>
+                       {% endif %}
+
                        {% if package.type == package.type.MOD %}
                                <div class="card my-4">
                                        <div class="card-header">Dependencies</div>
index 8fdca3fee72d9f648c9b1de6f76b61186e6deab3..fc197e87d4584c28ddb372ed1d8e37afe2427f2e 100644 (file)
@@ -7,7 +7,7 @@
 {% block content %}
 
 {% if not current_user.is_authenticated and user.rank == user.rank.NOT_JOINED and user.forums_username %}
-<div class="alert alert-info alert alert-info">
+<div class="alert alert-info">
        <a class="float-right btn btn-default btn-sm"
                href="{{ url_for('user_claim_page', username=user.forums_username) }}">Claim</a>
 
@@ -40,7 +40,7 @@
                                                        </td>
                                                </tr>
                                                <tr>
-                                                       <td>Accounts:</td>
+                                                       <td>Links:</td>
                                                        <td>
                                                                {% if user.forums_username %}
                                                                        <a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
@@ -50,7 +50,7 @@
                                                                        No forum account
                                                                {% endif %}
 
-                                                               {% if (user.forums_username and user.github_username) or user == current_user %}
+                                                               {% if user.github_username or user == current_user %}
                                                                        |
                                                                {% endif %}
 
                                                                        <a href="{{ url_for('github_signin_page') }}">Link Github</a>
                                                                {% endif %}
 
+                                                               {% if user.website_url %}
+                                                                       | <a href="{{ user.website_url }}" rel="nofollow">Website</a>
+                                                               {% endif %}
+
                                                                {% if user == current_user %}
-                                                                       &#x1f30e;
+                                                                       <br>
+                                                                       <small class="text-muted">
+                                                                               <span style="padding-right: 5px;">&#x1f30e;</span>
+                                                                               Visible to everyone
+                                                                       </small>
                                                                {% endif %}
                                                        </td>
                                                </tr>
 
                                        {% if user.checkPerm(current_user, "CHANGE_DNAME") %}
                                                {{ render_field(form.display_name, tabindex=230) }}
+                                               {{ render_field(form.website_url, tabindex=232) }}
+                                               {{ render_field(form.donate_url, tabindex=233) }}
                                        {% endif %}
 
                                        {% if user.checkPerm(current_user, "CHANGE_EMAIL") %}
 {% from "macros/packagegridtile.html" import render_pkggrid %}
 {{ render_pkggrid(packages, show_author=False) }}
 
+{% if user.donate_url %}
+       <div class="alert alert-secondary">
+               Like {{ user.display_name }}'s work?
+               <a href="{{ user.donate_url }}" rel="nofollow">Donate now!</a>
+       </div>
+{% endif %}
+
 {% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.EDITOR)) %}
        <div class="card mt-3">
                <a name="unadded-topics"></a>
index 02def2556e4723ce9bb6c611d93d2cfadab4b208..040950e797ddd58a3a24920496382d7c9b51aaa1 100644 (file)
@@ -32,6 +32,8 @@ from app.tasks.phpbbparser import getProfile
 class UserProfileForm(FlaskForm):
        display_name = StringField("Display name", [Optional(), Length(2, 20)])
        email = StringField("Email", [Optional(), Email()])
+       website_url = StringField("Website URL", [Optional(), URL()])
+       donate_url = StringField("Donation URL", [Optional(), URL()])
        rank = SelectField("Rank", [Optional()], choices=UserRank.choices(), coerce=UserRank.coerce, default=UserRank.NEW_MEMBER)
        submit = SubmitField("Save")
 
@@ -60,6 +62,8 @@ def user_profile_page(username):
                        # Copy form fields to user_profile fields
                        if user.checkPerm(current_user, Permission.CHANGE_DNAME):
                                user.display_name = form["display_name"].data
+                               user.website_url  = form["website_url"].data
+                               user.donate_url   = form["donate_url"].data
 
                        if user.checkPerm(current_user, Permission.CHANGE_RANK):
                                newRank = form["rank"].data
@@ -74,7 +78,7 @@ def user_profile_page(username):
                                        token = randomString(32)
 
                                        ver = UserEmailVerification()
-                                       ver.user = user
+                                       ver.user  = user
                                        ver.token = token
                                        ver.email = newEmail
                                        db.session.add(ver)
diff --git a/migrations/versions/d6ae9682c45f_.py b/migrations/versions/d6ae9682c45f_.py
new file mode 100644 (file)
index 0000000..7ab8de8
--- /dev/null
@@ -0,0 +1,30 @@
+"""empty message
+
+Revision ID: d6ae9682c45f
+Revises: 7ff57806ffd5
+Create Date: 2019-07-01 23:27:42.666877
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+
+# revision identifiers, used by Alembic.
+revision = 'd6ae9682c45f'
+down_revision = '7ff57806ffd5'
+branch_labels = None
+depends_on = None
+
+
+def upgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.add_column('user', sa.Column('donate_url', sa.String(length=255), nullable=True))
+    op.add_column('user', sa.Column('website_url', sa.String(length=255), nullable=True))
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.drop_column('user', 'website_url')
+    op.drop_column('user', 'donate_url')
+    # ### end Alembic commands ###