diff options
author | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-21 08:19:09 +0200 |
---|---|---|
committer | Cédric Bonhomme <cedric@cedricbonhomme.org> | 2016-09-21 08:19:09 +0200 |
commit | cb81d058e5738bd9d5a0fab3334dec2371ca5013 (patch) | |
tree | f23b8637ab3f669fb0ea0083e8a2a7ec4a450741 | |
parent | Add new stop words. (diff) | |
download | newspipe-cb81d058e5738bd9d5a0fab3334dec2371ca5013.tar.gz newspipe-cb81d058e5738bd9d5a0fab3334dec2371ca5013.tar.bz2 newspipe-cb81d058e5738bd9d5a0fab3334dec2371ca5013.zip |
add column webpage in the user table
-rw-r--r-- | migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py | 25 | ||||
-rw-r--r-- | src/web/forms.py | 3 | ||||
-rw-r--r-- | src/web/models/user.py | 3 | ||||
-rw-r--r-- | src/web/templates/profile.html | 3 | ||||
-rw-r--r-- | src/web/templates/profile_public.html | 7 | ||||
-rw-r--r-- | src/web/views/user.py | 3 |
6 files changed, 40 insertions, 4 deletions
diff --git a/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py b/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py new file mode 100644 index 00000000..4ff875b7 --- /dev/null +++ b/migrations/versions/16f8fc3cf0cc_add_column_webpage_in_the_user_table.py @@ -0,0 +1,25 @@ +"""add column webpage in the user table + +Revision ID: 16f8fc3cf0cc +Revises: 957d4c5b8ac9 +Create Date: 2016-09-21 08:00:27.160357 + +""" + +# revision identifiers, used by Alembic. +revision = '16f8fc3cf0cc' +down_revision = '957d4c5b8ac9' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + op.add_column('user', sa.Column('webpage', + sa.String(), default="")) + + +def downgrade(): + op.drop_column('user', 'webpage') diff --git a/src/web/forms.py b/src/web/forms.py index 4770f70c..905a0b2a 100644 --- a/src/web/forms.py +++ b/src/web/forms.py @@ -32,7 +32,7 @@ from flask_babel import lazy_gettext from werkzeug.exceptions import NotFound from wtforms import TextField, TextAreaField, PasswordField, BooleanField, \ SubmitField, IntegerField, SelectField, validators, HiddenField -from flask_wtf.html5 import EmailField +from flask_wtf.html5 import EmailField, URLField from web.lib import misc_utils from web.controllers import UserController @@ -159,6 +159,7 @@ class ProfileForm(Form): validators.Required(lazy_gettext("Please enter your email."))]) password = PasswordField(lazy_gettext("Password")) password_conf = PasswordField(lazy_gettext("Password Confirmation")) + webpage = URLField(lazy_gettext("Webpage")) refresh_rate = IntegerField(lazy_gettext("Feeds refresh frequency " "(in minutes)"), default=60) diff --git a/src/web/models/user.py b/src/web/models/user.py index 3e4ffcac..2e5d2f55 100644 --- a/src/web/models/user.py +++ b/src/web/models/user.py @@ -45,7 +45,10 @@ class User(db.Model, UserMixin, RightMixin): nickname = db.Column(db.String(), unique=True) email = db.Column(db.String(254), index=True, unique=True) pwdhash = db.Column(db.String()) + is_public_profile = db.Column(db.Boolean(), default=False) + webpage = db.Column(db.String(), default="") + date_created = db.Column(db.DateTime(), default=datetime.now) last_seen = db.Column(db.DateTime(), default=datetime.now) refresh_rate = db.Column(db.Integer, default=60) # in minutes diff --git a/src/web/templates/profile.html b/src/web/templates/profile.html index 8751446f..9b5db48a 100644 --- a/src/web/templates/profile.html +++ b/src/web/templates/profile.html @@ -37,6 +37,9 @@ {{ 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 %} + + {{ form.webpage.label }} + {{ form.webpage(class_="form-control") }} {% for error in form.webpage.errors %} <span style="color: red;">{{ error }}<br /></span>{% endfor %} <br /> {{ form.submit(class_="btn") }} </form> diff --git a/src/web/templates/profile_public.html b/src/web/templates/profile_public.html index c67a4e91..eac36441 100644 --- a/src/web/templates/profile_public.html +++ b/src/web/templates/profile_public.html @@ -4,8 +4,11 @@ <h1>{{ user.nickname }}</h1> <div class="row"> <div class="col-md-12"> - <p>{{ _('Member since') }} {{ user.date_created | datetime }}.</p> - <p>{{ _('Last seen:') }} {{ user.last_seen | datetime }}.</p> + <p>{{ _('Member since:') }} {{ user.date_created | datetime }}</p> + <p>{{ _('Last seen:') }} {{ user.last_seen | datetime }}</p> + {% if user.webpage %} + <p>{{ _('Webpage:') }} <a href="{{ user.webpage | safe }}">{{ user.webpage | safe }}</a></p> + {% endif %} </div> </div> diff --git a/src/web/views/user.py b/src/web/views/user.py index c7c318e3..df6508f5 100644 --- a/src/web/views/user.py +++ b/src/web/views/user.py @@ -107,7 +107,8 @@ def profile(): 'email': form.email.data, 'password': form.password.data, 'refresh_rate': form.refresh_rate.data, - 'is_public_profile': form.is_public_profile.data}) + 'is_public_profile': form.is_public_profile.data, + 'webpage': form.webpage.data}) flash(gettext('User %(nick)s successfully updated', nick=user.nickname), 'success') |