nattilypf: (Default)
[personal profile] nattilypf
June 27

In this commit, I have made a few changes and tightened up some of my models
code. I added in two major pieces of functionality: table foundations and a
decorator to confirm whether or not a user is a member of a certain group.

Table Foundations are default rows that should be present in a given table as
soon as the database is initialized. For example, I am using these to populate
the core__groups table with all of the necessary groups ('moderator', 'com-
menter', etc). Right now, this is achieved by adding a dictionary of parameters
(with the parameters as lists) to the constant FOUNDATIONS in
mediagoblin.db.models. The keys to this dictionary are uninstantiated classes.
The classes which require foundations also have must have a constructor so that
the list of parameters can be passed appropriately like so:
In order to implement these foundations, I added the method populate_table_fou-
-ndations to MigrationManager in mediagoblin.db.migration_tools.

The decorator, called user_in_group, accepts as a parameter a unicode string,
and then decides whether to redirect to 403 or let the user access the page. The
identifier is the Group.group_name string, because I believe that will allow for
the most readable code.

I also added in the simple decorator require_admin_login.

In terms of tightening up my code, I made many minor changes to my use of white
space and made a few small documentation additions. I removed a vestigial class
(ReportForm) from mediagoblin.user_pages.forms. I moved all of my migrations in-
to one registered Migration.

Setting up Foundations

--\ mediagoblin/db/
--| created: MigrationManager.populate_table_foundations
--| modified: MigrationManager.init_or_migrate to run
  | self.populate_table_foundations on init

--\ mediagoblin/db/
--| created: FOUNDATIONS
----| created: group_foundations

Working With Permissions
--\ mediagoblin/
--| created: user_in_group
--| created: require_admin_login

--\ mediagoblin/user_pages/
--| modified: added decorator user_in_group to file_a_report

--\ mediagoblin/admin/
--| modified: added decorator require_admin_login to all views functions

General Code Tidying

--/ mediagoblin/admin/
--/ mediagoblin/user_pages/
--/ mediagoblin/db/
--/ mediagoblin/user_pages/
--/ mediagoblin/user_pages/
--/ mediagoblin/db/
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
Account name:
If you don't have an account you can create one now.
HTML doesn't work in the subject.


Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

About Me

nattilypf: (Default)
Natalie Foust-Pilcher

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags

September 2013

1516171819 2021

Project To-Do List

~A summary of what I'm currently working on and what I still have yet to do~
Page generated Aug. 24th, 2017 06:48 am
Powered by Dreamwidth Studios