aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--migrations/versions/5553a6c05fa7_add_column_twitter_in_the_user_table.py25
-rw-r--r--src/web/forms.py1
-rw-r--r--src/web/models/user.py1
-rw-r--r--src/web/templates/profile.html3
-rw-r--r--src/web/templates/profile_public.html3
-rw-r--r--src/web/views/user.py3
6 files changed, 35 insertions, 1 deletions
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 %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+ {{ form.twitter.label }}
+ {{ form.twitter(class_="form-control") }} {% for error in form.twitter.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
+
{{ form.is_public_profile.label }}
{{ form.is_public_profile(class_="form-control") }} {% for error in form.is_public_profile.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %}
<p>{{ _('Your profile will be available <a href="%(url)s">here</a>.', url=url_for('user.profile_public', nickname=user.nickname) ) }}</p>
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 %}
<p>{{ _('Webpage') }}: <a href="{{ user.webpage | safe }}">{{ user.webpage | safe }}</a></p>
{% endif %}
+ {% if user.twitter %}
+ <p>{{ _('Twitter') }}: <a href="{{ user.twitter | safe }}">{{ user.twitter | safe }}</a></p>
+ {% endif %}
</div>
</div>
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')
bgstack15