From c8122e1981527a716639561cc3f880764f06387b Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Thu, 6 Oct 2016 11:09:21 +0200 Subject: The user can now add its twitter page. --- ...6c05fa7_add_column_twitter_in_the_user_table.py | 25 ++++++++++++++++++++++ src/web/forms.py | 1 + src/web/models/user.py | 1 + src/web/templates/profile.html | 3 +++ src/web/templates/profile_public.html | 3 +++ src/web/views/user.py | 3 ++- 6 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py diff --git a/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py b/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py new file mode 100644 index 00000000..7c7132a8 --- /dev/null +++ b/migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py @@ -0,0 +1,25 @@ +"""add column twitter in the user table + +Revision ID: 5553a6c05fa7 +Revises: f700c4237e9d +Create Date: 2016-10-06 11:02:41.356322 + +""" + +# revision identifiers, used by Alembic. +revision = '5553a6c05fa7' +down_revision = 'f700c4237e9d' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('user', sa.Column('twitter', + sa.String(), default="")) + + +def downgrade(): + op.drop_column('user', 'twitter') diff --git a/src/web/forms.py b/src/web/forms.py index f651c189..69abac46 100644 --- a/src/web/forms.py +++ b/src/web/forms.py @@ -157,6 +157,7 @@ class ProfileForm(Form): password = PasswordField(lazy_gettext("Password")) password_conf = PasswordField(lazy_gettext("Password Confirmation")) webpage = URLField(lazy_gettext("Webpage")) + twitter = URLField(lazy_gettext("Twitter")) is_public_profile = BooleanField(lazy_gettext("Public profile"), default=True) submit = SubmitField(lazy_gettext("Save")) diff --git a/src/web/models/user.py b/src/web/models/user.py index c8ed33f8..59c4ad38 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -50,6 +50,7 @@ class User(db.Model, UserMixin, RightMixin): is_public_profile = db.Column(db.Boolean(), default=False) webpage = db.Column(db.String(), default="") + twitter = db.Column(db.String(), default="") date_created = db.Column(db.DateTime(), default=datetime.utcnow) last_seen = db.Column(db.DateTime(), default=datetime.utcnow) diff --git a/src/web/templates/profile.html b/src/web/templates/profile.html index a8eac38f..d21608cf 100644 --- a/src/web/templates/profile.html +++ b/src/web/templates/profile.html @@ -36,6 +36,9 @@ {{ form.webpage.label }} {{ form.webpage(class_="form-control") }} {% for error in form.webpage.errors %} {{ error }}
{% endfor %} + {{ form.twitter.label }} + {{ form.twitter(class_="form-control") }} {% for error in form.twitter.errors %} {{ error }}
{% endfor %} + {{ form.is_public_profile.label }} {{ form.is_public_profile(class_="form-control") }} {% for error in form.is_public_profile.errors %} {{ error }}
{% endfor %}

{{ _('Your profile will be available here.', url=url_for('user.profile_public', nickname=user.nickname) ) }}

diff --git a/src/web/templates/profile_public.html b/src/web/templates/profile_public.html index ea13ae63..aed5bfcc 100644 --- a/src/web/templates/profile_public.html +++ b/src/web/templates/profile_public.html @@ -9,6 +9,9 @@ {% if user.webpage %}

{{ _('Webpage') }}: {{ user.webpage | safe }}

{% endif %} + {% if user.twitter %} +

{{ _('Twitter') }}: {{ user.twitter | safe }}

+ {% endif %} diff --git a/src/web/views/user.py b/src/web/views/user.py index b877f9c7..bf568d69 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -108,7 +108,8 @@ def profile(): 'email': form.email.data, 'password': form.password.data, 'is_public_profile': form.is_public_profile.data, - 'webpage': form.webpage.data}) + 'webpage': form.webpage.data, + 'twitter': form.twitter.data}) flash(gettext('User %(nick)s successfully updated', nick=user.nickname), 'success') -- cgit