aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/auth
diff options
context:
space:
mode:
authortilly-Q <nattilypigeonfowl@gmail.com>2013-07-03 14:46:21 -0400
committertilly-Q <nattilypigeonfowl@gmail.com>2013-07-03 14:46:21 -0400
commit3fb96fc97800ae032e599006e3f49ffd69926c88 (patch)
tree93c19ff89864f065cb8fea5a313d76a1f8c09c0b /mediagoblin/auth
parent9b8ef022ef874304fb3d5aead612ec3b8fb23e9a (diff)
downloadmediagoblin-3fb96fc97800ae032e599006e3f49ffd69926c88.tar.lz
mediagoblin-3fb96fc97800ae032e599006e3f49ffd69926c88.tar.xz
mediagoblin-3fb96fc97800ae032e599006e3f49ffd69926c88.zip
This was a simple commit. I changed all references to Groups into Privileges so
as to not conflict with the new federated groups which are also being written. I also fixed up some of the code in the user_in_group/user_has_privilege decor- ator. Users are now assigned the default privileges when they sign up, and ass- iged active once they are activated. I updated the gmg command makeadmin to use my groups as well. Lastly, I added the decorator to various views, requiring th- at users belong to appropriate groups to access pages. --\ mediagoblin/auth/tools.py --| Added code to assign new users to default privileges --\ mediagoblin/auth/views.py --| Added code to assign users to u'active' privilege once the email | verification is complete --\ mediagoblin/db/migrations.py --| Renamed Group class to Privilege class --\ mediagoblin/db/models.py --| Renamed Group class to Privilege class --\ mediagoblin/decorators.py --| Renamed function based on the Group->Privilege change --| Rewrote the function to be, ya know, functional --\ mediagoblin/gmg_commands/users.py --| Changed the 'makeadmin' command to add the target user to the admin | privilege group as well as affecting 'is_admin' column --\ mediagoblin/submit/views.py --| Added the requirement that a user has the 'uploader' privilege in order | to submit new media. --\ mediagoblin/user_pages/views.py --| Added the requirement that a user has the 'commenter' privilege in order | to make a comment. --| Added the requirement that a user has the 'reporter' privilege in order | to submit new reports. --| Got rid of some vestigial code in the file_a_report function.
Diffstat (limited to 'mediagoblin/auth')
-rw-r--r--mediagoblin/auth/tools.py10
-rw-r--r--mediagoblin/auth/views.py5
2 files changed, 13 insertions, 2 deletions
diff --git a/mediagoblin/auth/tools.py b/mediagoblin/auth/tools.py
index db6b6e37..39b349de 100644
--- a/mediagoblin/auth/tools.py
+++ b/mediagoblin/auth/tools.py
@@ -22,7 +22,7 @@ from sqlalchemy import or_
from mediagoblin import mg_globals
from mediagoblin.auth import lib as auth_lib
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, Privilege
from mediagoblin.tools.mail import (normalize_email, send_email,
email_debug_message)
from mediagoblin.tools.template import render_template
@@ -130,6 +130,14 @@ def register_user(request, register_form):
user.verification_key = unicode(uuid.uuid4())
user.save()
+ # give the user the default privileges
+ default_privileges = [
+ Privilege.query.filter(Privilege.privilege_name==u'commenter').first(),
+ Privilege.query.filter(Privilege.privilege_name==u'uploader').first(),
+ Privilege.query.filter(Privilege.privilege_name==u'reporter').first()]
+ user.all_privileges += default_privileges
+ user.save()
+
# log the user in
request.session['user_id'] = unicode(user.id)
request.session.save()
diff --git a/mediagoblin/auth/views.py b/mediagoblin/auth/views.py
index bb7bda77..1c346556 100644
--- a/mediagoblin/auth/views.py
+++ b/mediagoblin/auth/views.py
@@ -18,7 +18,7 @@ import uuid
import datetime
from mediagoblin import messages, mg_globals
-from mediagoblin.db.models import User
+from mediagoblin.db.models import User, Privilege
from mediagoblin.tools.response import render_to_response, redirect, render_404
from mediagoblin.tools.translate import pass_to_ugettext as _
from mediagoblin.tools.mail import email_debug_message
@@ -124,6 +124,9 @@ def verify_email(request):
user.status = u'active'
user.email_verified = True
user.verification_key = None
+ user.all_privileges.append(
+ Privilege.query.filter(
+ Privilege.privilege_name==u'active').first())
user.save()