16 |
16 |
17 """Views for Clubs. |
17 """Views for Clubs. |
18 """ |
18 """ |
19 |
19 |
20 __authors__ = [ |
20 __authors__ = [ |
|
21 '"Sverre Rabbelier" <sverre@rabbelier.nl>', |
21 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
22 '"Lennard de Rijk" <ljvderijk@gmail.com>', |
22 ] |
23 ] |
23 |
24 |
24 |
25 |
25 from google.appengine.api import users |
26 from google.appengine.api import users |
26 |
27 |
27 from django import forms |
28 from django import forms |
28 |
29 |
29 from soc.logic import dicts |
30 from soc.logic import dicts |
30 from soc.logic.models import user as user_logic |
31 from soc.logic.models import user as user_logic |
|
32 from soc.logic.models import group_app as group_app_logic |
|
33 from soc.logic.models import club as club_logic |
31 from soc.views.helper import widgets |
34 from soc.views.helper import widgets |
32 from soc.views.models import base |
35 from soc.views.models import base |
33 |
36 |
34 import soc.logic.models.club |
37 import soc.logic.models.club |
35 |
38 |
50 |
53 |
51 new_params['logic'] = soc.logic.models.club.logic |
54 new_params['logic'] = soc.logic.models.club.logic |
52 |
55 |
53 new_params['name'] = "Club" |
56 new_params['name'] = "Club" |
54 |
57 |
55 new_params['extra_dynaexclude'] = ['founder', 'home'] |
58 new_params['extra_dynaexclude'] = ['founder', 'home', 'member_template'] |
56 new_params['edit_extra_dynafields'] = { |
59 new_params['edit_extra_dynafields'] = { |
57 'founded_by': forms.CharField(widget=widgets.ReadOnlyInput(), |
60 'founded_by': forms.CharField(widget=widgets.ReadOnlyInput(), |
58 required=False), |
61 required=False), |
59 } |
62 } |
60 |
63 |
61 params = dicts.merge(params, new_params) |
64 params = dicts.merge(params, new_params) |
62 |
65 |
63 super(View, self).__init__(params=params) |
66 super(View, self).__init__(params=params) |
|
67 |
|
68 def create(self, request, access_type, |
|
69 page_name=None, params=None, **kwargs): |
|
70 """See base.View.create() |
|
71 """ |
|
72 |
|
73 if 'link_id' not in kwargs: |
|
74 return super(View, self).create(request, access_type, page_name, |
|
75 params=params, **kwargs) |
|
76 |
|
77 # Find their application |
|
78 key_fields = group_app_logic.logic.getKeyFieldsFromDict(kwargs) |
|
79 application = group_app_logic.logic.getFromFields(**key_fields) |
|
80 |
|
81 # Extract the application fields |
|
82 field_names = application.properties().keys() |
|
83 fields = dict( [(i, getattr(application, i)) for i in field_names] ) |
|
84 |
|
85 empty = dict( [(i, None) for i in self._logic.getKeyFieldNames()] ) |
|
86 |
|
87 return super(View, self).edit(request, access_type, page_name, |
|
88 params=params, seed=fields, **empty) |
64 |
89 |
65 def _editGet(self, request, entity, form): |
90 def _editGet(self, request, entity, form): |
66 """See base.View._editGet(). |
91 """See base.View._editGet(). |
67 """ |
92 """ |
68 |
93 |