From 3fb96fc97800ae032e599006e3f49ffd69926c88 Mon Sep 17 00:00:00 2001 From: tilly-Q Date: Wed, 3 Jul 2013 14:46:21 -0400 Subject: 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. --- mediagoblin/db/models.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'mediagoblin/db/models.py') diff --git a/mediagoblin/db/models.py b/mediagoblin/db/models.py index 28e01a85..e0419c92 100644 --- a/mediagoblin/db/models.py +++ b/mediagoblin/db/models.py @@ -559,50 +559,50 @@ class UserBan(Base): reason = Column(UnicodeText, nullable=False) -class Group(Base): - __tablename__ = 'core__groups' +class Privilege(Base): + __tablename__ = 'core__privileges' id = Column(Integer, nullable=False, primary_key=True) - group_name = Column(Unicode, nullable=False, unique=True) + privilege_name = Column(Unicode, nullable=False, unique=True) all_users = relationship( User, - backref='all_groups', - secondary="core__group_user_associations") + backref='all_privileges', + secondary="core__privileges_users") - def __init__(self, group_name): - self.group_name = group_name + def __init__(self, privilege_name): + self.privilege_name = privilege_name def __repr__(self): - return "" % (self.group_name) + return "" % (self.privilege_name) -class GroupUserAssociation(Base): - __tablename__ = 'core__group_user_associations' +class PrivilegeUserAssociation(Base): + __tablename__ = 'core__privileges_users' - group_id = Column( - 'core__group_id', + privilege_id = Column( + 'core__privilege_id', Integer, ForeignKey(User.id), primary_key=True) user_id = Column( 'core__user_id', Integer, - ForeignKey(Group.id), + ForeignKey(Privilege.id), primary_key=True) -group_foundations = [[u'admin'], [u'moderator'], [u'commenter'], [u'uploader'],[u'reporter'],[u'active']] +privilege_foundations = [[u'admin'], [u'moderator'], [u'commenter'], [u'uploader'],[u'reporter'],[u'active']] MODELS = [ User, MediaEntry, Tag, MediaTag, MediaComment, Collection, CollectionItem, MediaFile, FileKeynames, MediaAttachmentFile, ProcessingMetaData, ReportBase, - CommentReport, MediaReport, UserBan, Group, GroupUserAssociation] + CommentReport, MediaReport, UserBan, Privilege, PrivilegeUserAssociation] # Foundations are the default rows that are created immediately after the tables are initialized. Each entry to # this dictionary should be in the format of # ModelObject:List of Rows # (Each Row must be a list of parameters that can create and instance of the ModelObject) # -FOUNDATIONS = {Group:group_foundations} +FOUNDATIONS = {Privilege:privilege_foundations} ###################################################### # Special, migrations-tracking table -- cgit v1.2.3