# HG changeset patch # User Sverre Rabbelier # Date 1231611490 0 # Node ID 95c534d02e39a7a5d5d161c32f7ac9464cb32128 # Parent 06a84103ed8b5e8e3355166e78f8d61f0c8b72b9 Added Club Admin model, logic, and view Patch by: Sverre Rabbelier diff -r 06a84103ed8b -r 95c534d02e39 app/soc/logic/models/club_admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/logic/models/club_admin.py Sat Jan 10 18:18:10 2009 +0000 @@ -0,0 +1,45 @@ +#!/usr/bin/python2.5 +# +# Copyright 2008 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Club Admin (Model) query functions. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from soc.logic.models import role +from soc.logic.models import club as club_logic + +import soc.models.club_admin +import soc.models.role + + +class Logic(role.Logic): + """Logic methods for the Club Admin model. + """ + + def __init__(self, model=soc.models.club_admin.ClubAdmin, + base_model=soc.models.role.Role, scope_logic=club_logic): + """Defines the name, key_name and model for this entity. + """ + + super(Logic, self).__init__(model=model, base_model=base_model, + scope_logic=scope_logic) + + +logic = Logic() diff -r 06a84103ed8b -r 95c534d02e39 app/soc/models/club_admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/models/club_admin.py Sat Jan 10 18:18:10 2009 +0000 @@ -0,0 +1,39 @@ +#!/usr/bin/python2.5 +# +# Copyright 2008 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This module contains the Club Admin Model.""" + +__authors__ = [ + '"Sverre Rabbelier" ', +] + + +from google.appengine.ext import db + +import soc.models.role +import soc.models.club + + +class ClubAdmin(soc.models.role.Role): + """Admin for a specific Club. + """ + + #: A many:1 relationship associating Admins with specific Club + #: details and capabilities. The back-reference in the Club model + #: is a Query named 'admins'. + org = db.ReferenceProperty( + reference_class=soc.models.club.Club, + required=True, collection_name='admins') diff -r 06a84103ed8b -r 95c534d02e39 app/soc/views/helper/access.py --- a/app/soc/views/helper/access.py Sat Jan 10 18:17:44 2009 +0000 +++ b/app/soc/views/helper/access.py Sat Jan 10 18:18:10 2009 +0000 @@ -321,6 +321,25 @@ raise out_of_band.LoginRequest(message_fmt=login_message_fmt) +def checkIsApplied(request): + """Returns an alternate HTTP response if Google Account has no Club App + entity for the specified Club. + + Args: + request: a Django HTTP request + + Raises: + AccessViolationResponse: if the required authorization is not met + + Returns: + None if Club App exists for the specified program, or a subclass + of django.http.HttpResponse which contains the alternate response + should be returned by the calling view. + """ + + #TODO(srabbelier): implement this + pass + def checkIsMyNotification(request): """Returns an alternate HTTP response if this request is for a Notification belonging to the current user. diff -r 06a84103ed8b -r 95c534d02e39 app/soc/views/models/club.py --- a/app/soc/views/models/club.py Sat Jan 10 18:17:44 2009 +0000 +++ b/app/soc/views/models/club.py Sat Jan 10 18:18:10 2009 +0000 @@ -31,6 +31,7 @@ from soc.logic.models import user as user_logic from soc.logic.models import group_app as group_app_logic from soc.logic.models import club as club_logic +from soc.views.helper import access from soc.views.helper import widgets from soc.views.models import base @@ -49,9 +50,12 @@ params: a dict with params for this View """ + rights = {} + rights['create'] = [access.checkIsApplied] + new_params = {} - new_params['logic'] = soc.logic.models.club.logic + new_params['rights'] = rights new_params['name'] = "Club" diff -r 06a84103ed8b -r 95c534d02e39 app/soc/views/models/club_admin.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/views/models/club_admin.py Sat Jan 10 18:18:10 2009 +0000 @@ -0,0 +1,70 @@ +#!/usr/bin/python2.5 +# +# Copyright 2008 the Melange authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Views for Club Admins. +""" + +__authors__ = [ + '"Sverre Rabbelier" ', + ] + + +from django import forms + +from soc.logic import cleaning +from soc.logic import dicts +from soc.views.helper import redirects +from soc.views.models import base +from soc.views.models import club as club_view + +import soc.logic.models.club_admin + + +class View(base.View): + """View methods for the Program model. + """ + + def __init__(self, params=None): + """Defines the fields and methods required for the base View class + to provide the user with list, public, create, edit and delete views. + + Params: + params: a dict with params for this View + """ + + new_params = {} + new_params['logic'] = soc.logic.models.club_admin.logic + + new_params['scope_view'] = club_view + new_params['scope_redirect'] = redirects.getCreateRedirect + + new_params['name'] = "Club Admin" + + new_params['extra_dynaexclude'] = ['user', 'org'] + + params = dicts.merge(params, new_params) + + super(View, self).__init__(params=params) + + + +view = View() + +create = view.create +delete = view.delete +edit = view.edit +list = view.list +public = view.public diff -r 06a84103ed8b -r 95c534d02e39 app/soc/views/sitemap/build.py --- a/app/soc/views/sitemap/build.py Sat Jan 10 18:17:44 2009 +0000 +++ b/app/soc/views/sitemap/build.py Sat Jan 10 18:18:10 2009 +0000 @@ -26,6 +26,7 @@ from soc.views.models import club from soc.views.models import club_app +from soc.views.models import club_admin from soc.views.models import document from soc.views.models import host from soc.views.models import notification @@ -46,6 +47,7 @@ sidebar.addMenu(user_self.view.getSidebarMenus) sidebar.addMenu(presence.view.getSidebarMenus) sidebar.addMenu(club.view.getSidebarMenus) +sidebar.addMenu(club_admin.view.getSidebarMenus) sidebar.addMenu(club_app.view.getSidebarMenus) sidebar.addMenu(site.view.getSidebarMenus) sidebar.addMenu(user.view.getSidebarMenus) @@ -58,6 +60,7 @@ sidebar.addMenu(organization.view.getSidebarMenus) sitemap.addPages(club.view.getDjangoURLPatterns()) +sitemap.addPages(club_admin.view.getDjangoURLPatterns()) sitemap.addPages(club_app.view.getDjangoURLPatterns()) sitemap.addPages(document.view.getDjangoURLPatterns()) sitemap.addPages(host.view.getDjangoURLPatterns())