Add website and donation support

This commit is contained in:
rubenwardy 2019-07-02 00:45:04 +01:00
parent 7b087158d7
commit b36273a848
6 changed files with 72 additions and 10 deletions

@ -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) ## 5. Promotions and Advertisements (inc. asking for donations)
Any information other than the long description - including screenshots - must You may note place any promotions or advertisements in any meta data including
not contain any promotions or advertisements. This includes asking for donations, screensthos. This includes asking for donations, promoting online shops,
promoting online shops, or linking to personal websites and social media. 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 ContentDB is for the community. We may remove any promotions if we feel that
they're inappropriate. they're inappropriate.
Paid promotions are not allowed at all, anywhere.
## 6. Reporting Violations ## 6. Reporting Violations

@ -129,6 +129,10 @@ class User(db.Model, UserMixin):
active = db.Column("is_active", db.Boolean, nullable=False, server_default="0") active = db.Column("is_active", db.Boolean, nullable=False, server_default="0")
display_name = db.Column(db.String(100), nullable=False, server_default="") 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 # Content
notifications = db.relationship("Notification", primaryjoin="User.id==Notification.user_id") notifications = db.relationship("Notification", primaryjoin="User.id==Notification.user_id")

@ -217,6 +217,13 @@
</table> </table>
</div> </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 %} {% if package.type == package.type.MOD %}
<div class="card my-4"> <div class="card my-4">
<div class="card-header">Dependencies</div> <div class="card-header">Dependencies</div>

@ -7,7 +7,7 @@
{% block content %} {% block content %}
{% if not current_user.is_authenticated and user.rank == user.rank.NOT_JOINED and user.forums_username %} {% 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" <a class="float-right btn btn-default btn-sm"
href="{{ url_for('user_claim_page', username=user.forums_username) }}">Claim</a> href="{{ url_for('user_claim_page', username=user.forums_username) }}">Claim</a>
@ -40,7 +40,7 @@
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Accounts:</td> <td>Links:</td>
<td> <td>
{% if user.forums_username %} {% if user.forums_username %}
<a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}"> <a href="https://forum.minetest.net/memberlist.php?mode=viewprofile&un={{ user.forums_username }}">
@ -50,7 +50,7 @@
No forum account No forum account
{% endif %} {% endif %}
{% if (user.forums_username and user.github_username) or user == current_user %} {% if user.github_username or user == current_user %}
| |
{% endif %} {% endif %}
@ -60,8 +60,16 @@
<a href="{{ url_for('github_signin_page') }}">Link Github</a> <a href="{{ url_for('github_signin_page') }}">Link Github</a>
{% endif %} {% endif %}
{% if user.website_url %}
| <a href="{{ user.website_url }}" rel="nofollow">Website</a>
{% endif %}
{% if user == current_user %} {% if user == current_user %}
&#x1f30e; <br>
<small class="text-muted">
<span style="padding-right: 5px;">&#x1f30e;</span>
Visible to everyone
</small>
{% endif %} {% endif %}
</td> </td>
</tr> </tr>
@ -136,6 +144,8 @@
{% if user.checkPerm(current_user, "CHANGE_DNAME") %} {% if user.checkPerm(current_user, "CHANGE_DNAME") %}
{{ render_field(form.display_name, tabindex=230) }} {{ render_field(form.display_name, tabindex=230) }}
{{ render_field(form.website_url, tabindex=232) }}
{{ render_field(form.donate_url, tabindex=233) }}
{% endif %} {% endif %}
{% if user.checkPerm(current_user, "CHANGE_EMAIL") %} {% if user.checkPerm(current_user, "CHANGE_EMAIL") %}
@ -158,6 +168,13 @@
{% from "macros/packagegridtile.html" import render_pkggrid %} {% from "macros/packagegridtile.html" import render_pkggrid %}
{{ render_pkggrid(packages, show_author=False) }} {{ 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)) %} {% if current_user == user or (current_user.is_authenticated and current_user.rank.atLeast(current_user.rank.EDITOR)) %}
<div class="card mt-3"> <div class="card mt-3">
<a name="unadded-topics"></a> <a name="unadded-topics"></a>

@ -32,6 +32,8 @@ from app.tasks.phpbbparser import getProfile
class UserProfileForm(FlaskForm): class UserProfileForm(FlaskForm):
display_name = StringField("Display name", [Optional(), Length(2, 20)]) display_name = StringField("Display name", [Optional(), Length(2, 20)])
email = StringField("Email", [Optional(), Email()]) 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) rank = SelectField("Rank", [Optional()], choices=UserRank.choices(), coerce=UserRank.coerce, default=UserRank.NEW_MEMBER)
submit = SubmitField("Save") submit = SubmitField("Save")
@ -60,6 +62,8 @@ def user_profile_page(username):
# Copy form fields to user_profile fields # Copy form fields to user_profile fields
if user.checkPerm(current_user, Permission.CHANGE_DNAME): if user.checkPerm(current_user, Permission.CHANGE_DNAME):
user.display_name = form["display_name"].data 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): if user.checkPerm(current_user, Permission.CHANGE_RANK):
newRank = form["rank"].data newRank = form["rank"].data
@ -74,7 +78,7 @@ def user_profile_page(username):
token = randomString(32) token = randomString(32)
ver = UserEmailVerification() ver = UserEmailVerification()
ver.user = user ver.user = user
ver.token = token ver.token = token
ver.email = newEmail ver.email = newEmail
db.session.add(ver) db.session.add(ver)

@ -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 ###