diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
index 7d95b81a..5e2a2af0 100644
--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -150,9 +150,7 @@ def verify_email(request):
user = User.query.filter_by(id=int(token)).first()
- if user and user.email_verified is False:
- user.status = u'active'
- user.email_verified = True
+ if user and user.has_privilege(u'active') is False:
user.verification_key = None
user.all_privileges.append(
Privilege.query.filter(
@@ -191,7 +189,7 @@ def resend_activation(request):
return redirect(request, 'mediagoblin.auth.login')
- if request.user.email_verified:
+ if request.user.has_privilege(u'active'):
messages.add_message(
request,
messages.ERROR,
@@ -256,7 +254,7 @@ def forgot_password(request):
success_message=_("An email has been sent with instructions "
"on how to change your password.")
- if user and not(user.email_verified and user.status == 'active'):
+ if user and not(user.has_privilege(u'active')):
# Don't send reminder because user is inactive or has no verified email
messages.add_message(request,
messages.WARNING,
@@ -312,8 +310,8 @@ def verify_forgot_password(request):
return redirect(
request, 'index')
- # check if user active and has email verified
- if user.email_verified and user.status == 'active':
+ # check if user active
+ if user.has_privilege(u'active'):
cp_form = auth_forms.ChangePassForm(formdata_vars)
@@ -333,13 +331,13 @@ def verify_forgot_password(request):
'mediagoblin/auth/change_fp.html',
{'cp_form': cp_form,})
- if not user.email_verified:
+ if not user.has_privilege(u'active'):
messages.add_message(
request, messages.ERROR,
_('You need to verify your email before you can reset your'
' password.'))
- if not user.status == 'active':
+ if not user.has_privilege(u'active'):
messages.add_message(
request, messages.ERROR,
_('You are no longer an active user. Please contact the system'
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 6659feb3..1c0a9291 100644
--- a/mediagoblin/db/migrations.py
+++ b/mediagoblin/db/migrations.py
@@ -29,7 +29,8 @@ from migrate.changeset.constraint import UniqueConstraint
from mediagoblin.db.extratypes import JSONEncoded
from mediagoblin.db.migration_tools import RegisterMigration, inspect_table
from mediagoblin.db.models import (MediaEntry, Collection, User,
- MediaComment, Privilege, ReportBase)
+ MediaComment, Privilege, ReportBase,
+ FOUNDATIONS)
MIGRATIONS = {}
@@ -531,6 +532,40 @@ def create_moderation_tables(db):
UserBan_v0.__table__.create(db.bind)
Privilege_v0.__table__.create(db.bind)
PrivilegeUserAssociation_v0.__table__.create(db.bind)
+
db.commit()
+ for parameters in FOUNDATIONS[Privilege]:
+ p = Privilege(**parameters)
+ p.save()
+
+@RegisterMigration(16, MIGRATIONS)
+def update_user_privilege_columns(db):
+ metadata = MetaData(bind=db.bind)
+ default_privileges = Privilege.query.filter(
+ Privilege.privilege_name !=u'admin').filter(
+ Privilege.privilege_name !=u'moderator').filter(
+ Privilege.privilege_name !=u'active').all()
+ admin_privilege = Privilege.query.filter(
+ Privilege.privilege_name ==u'admin').first()
+ active_privilege = Privilege.query.filter(
+ Privilege.privilege_name ==u'active').first()
+ for inactive_user in User.query.filter(
+ User.status!=u'active').filter(
+ User.is_admin==False).all():
+
+ inactive_user.all_privileges = default_privileges
+ inactive_user.save()
+ for user in User.query.filter(
+ User.status==u'active').filter(
+ User.is_admin==False).all():
+
+ user.all_privileges = default_privileges + [active_privilege]
+ user.save()
+ for admin_user in User.query.filter(
+ User.is_admin==True).all():
+
+ admin_user.all_privileges = default_privileges + [
+ admin_privilege, active_privilege]
+ admin_user.save()
diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py
index f25dc32c..5b77a85d 100644
--- a/mediagoblin/db/models.py
+++ b/mediagoblin/db/models.py
@@ -81,8 +81,8 @@ class User(Base, UserMixin):
return '<{0} #{1} {2} {3} "{4}">'.format(
self.__class__.__name__,
self.id,
- 'verified' if self.email_verified else 'non-verified',
- 'admin' if self.is_admin else 'user',
+ 'verified' if self.has_privilege(u'active') else 'non-verified',
+ 'admin' if self.has_privilege(u'admin') else 'user',
self.username)
def delete(self, **kwargs):
diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py
index d319cef9..4a730d9e 100644
--- a/mediagoblin/gmg_commands/users.py
+++ b/mediagoblin/gmg_commands/users.py
@@ -53,8 +53,6 @@ def adduser(args):
entry.username = unicode(args.username.lower())
entry.email = unicode(args.email)
entry.pw_hash = auth.gen_password_hash(args.password)
- entry.status = u'active'
- entry.email_verified = True
default_privileges = [
db.Privilege.query.filter(
db.Privilege.privilege_name==u'commenter').one(),
diff --git a/mediagoblin/meta/routing.py b/mediagoblin/meta/routing.py
index e61bc065..b74cb52d 100644
--- a/mediagoblin/meta/routing.py
+++ b/mediagoblin/meta/routing.py
@@ -15,9 +15,9 @@
# along with this program. If not, see
diff --git a/mediagoblin/templates/mediagoblin/meta/terms_of_service.html b/mediagoblin/templates/mediagoblin/meta/terms_of_service.html
index 0951c044..b998d1c3 100644
--- a/mediagoblin/templates/mediagoblin/meta/terms_of_service.html
+++ b/mediagoblin/templates/mediagoblin/meta/terms_of_service.html
@@ -1,3 +1,27 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see {% trans %}Sorry, no such user found.{% endtrans %}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/collection_list.html b/mediagoblin/templates/mediagoblin/user_pages/collection_list.html
index 8ac0b988..4b449c76 100644
--- a/mediagoblin/templates/mediagoblin/user_pages/collection_list.html
+++ b/mediagoblin/templates/mediagoblin/user_pages/collection_list.html
@@ -34,7 +34,7 @@
{% if request.user %}
- {% if request.user.status == 'active' %}
+ {% if request.user.has_privilege('active') %}
The gist
Terms of Service
@@ -14,8 +38,8 @@ that may be published from time to time on this Site by Operator (collectively,
Please read this Agreement carefully before accessing or using the Website. By accessing or using any part of the web site, you agree to become bound by the terms and conditions of this agreement. If you do not agree to all the terms and conditions of this agreement, then you may not access the Website or use any services. If these terms and conditions are considered an offer by Operator, acceptance is expressly limited to these terms. The Website is available only to individuals who are at least 13 years old.
-
-
+
+
{% trans %}Email verification needed{% endtrans %}