# HG changeset patch # User Lennard de Rijk # Date 1231435357 0 # Node ID 27924b0f13cd061c0aa95fb2e4aab09111b5962c # Parent 35a2d07e04e804df75cab8158f29574124c8285a Fixed missing files in r1364. Patch by: Lennard de Rijk diff -r 35a2d07e04e8 -r 27924b0f13cd app/soc/logic/models/club.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/logic/models/club.py Thu Jan 08 17:22:37 2009 +0000 @@ -0,0 +1,44 @@ +#!/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 (Model) query functions. +""" + +__authors__ = [ + '"Lennard de Rijk" ', + ] + + +from soc.logic.models import group + +import soc.models.club +import soc.models.group + + +class Logic(group.Logic): + """Logic methods for the Club model. + """ + + def __init__(self, model=soc.models.club.Club, + base_model=soc.models.group, scope_logic=None): + """Defines the name, key_name and model for this entity. + """ + + super(Logic, self).__init__(model, base_model=base_model, + scope_logic=scope_logic) + + +logic = Logic() diff -r 35a2d07e04e8 -r 27924b0f13cd app/soc/views/models/club.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/app/soc/views/models/club.py Thu Jan 08 17:22:37 2009 +0000 @@ -0,0 +1,101 @@ +#!/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 Clubs. +""" + +__authors__ = [ + '"Lennard de Rijk" ', + ] + + +from google.appengine.api import users + +from django import forms + +from soc.logic import dicts +from soc.logic.models import user as user_logic +from soc.views.helper import widgets +from soc.views.models import base + +import soc.logic.models.club + + +class View(base.View): + """View methods for the Club 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.logic + + new_params['name'] = "Club" + new_params['name_short'] = "Club" + new_params['name_plural'] = "Clubs" + new_params['url_name'] = "club" + new_params['module_name'] = "club" + + new_params['extra_dynaexclude'] = ['founder', 'home'] + new_params['edit_extra_dynafields'] = { + 'founded_by': forms.CharField(widget=widgets.ReadOnlyInput(), + required=False), + } + + # TODO(tlarsen): Add support for Django style template lookup + new_params['public_template'] = 'soc/club/public.html' + + new_params['list_row'] = 'soc/club/list/row.html' + new_params['list_heading'] = 'soc/club/list/heading.html' + + params = dicts.merge(params, new_params) + + super(View, self).__init__(params=params) + + def _editGet(self, request, entity, form): + """See base.View._editGet(). + """ + + # fill in the founded_by with data from the entity + form.fields['founded_by'].initial = entity.founder.name + super(View, self)._editGet(request, entity, form) + + def _editPost(self, request, entity, fields): + """See base.View._editPost(). + """ + + if not entity: + # only if we are creating a new entity we should fill in founder + account = users.get_current_user() + user = user_logic.logic.getForFields({'account': account}, unique=True) + fields['founder'] = user + + super(View, self)._editPost(request, entity, fields) + +view = View() + +create = view.create +delete = view.delete +edit = view.edit +list = view.list +public = view.public \ No newline at end of file