29 from soc.views.models import base |
29 from soc.views.models import base |
30 from soc.views.models import role |
30 from soc.views.models import role |
31 |
31 |
32 import soc.models.host |
32 import soc.models.host |
33 import soc.logic.models.host |
33 import soc.logic.models.host |
|
34 import soc.logic.models.sponsor |
34 import soc.views.helper |
35 import soc.views.helper |
35 |
36 |
36 |
37 |
37 class CreateForm(helper.forms.BaseForm): |
38 class CreateForm(helper.forms.BaseForm): |
38 """Django form displayed when creating a Host. |
39 """Django form displayed when creating a Host. |
69 """Django form displayed when editing a Host. |
70 """Django form displayed when editing a Host. |
70 """ |
71 """ |
71 |
72 |
72 pass |
73 pass |
73 |
74 |
74 class View(base.View): |
75 class View(role.RoleView): |
75 """View methods for the Host model |
76 """View methods for the Host model |
76 """ |
77 """ |
77 |
78 |
78 def __init__(self, original_params=None, original_rights=None): |
79 def __init__(self, original_params=None, original_rights=None): |
79 """Defines the fields and methods required for the base View class |
80 """Defines the fields and methods required for the base View class |
87 self._logic = soc.logic.models.host.logic |
88 self._logic = soc.logic.models.host.logic |
88 |
89 |
89 params = {} |
90 params = {} |
90 rights = {} |
91 rights = {} |
91 |
92 |
|
93 params['logic'] = soc.logic.models.host.logic |
|
94 params['group_logic'] = soc.logic.models.sponsor.logic |
|
95 params['invite_filter'] = {'group_ln': 'link_name'} |
|
96 |
92 params['name'] = "Host" |
97 params['name'] = "Host" |
93 params['name_short'] = "Host" |
98 params['name_short'] = "Host" |
94 params['name_plural'] = "Hosts" |
99 params['name_plural'] = "Hosts" |
95 |
100 |
96 params['edit_form'] = EditForm |
101 params['edit_form'] = EditForm |
98 |
103 |
99 # TODO(tlarsen) Add support for Django style template lookup |
104 # TODO(tlarsen) Add support for Django style template lookup |
100 params['edit_template'] = 'soc/models/edit.html' |
105 params['edit_template'] = 'soc/models/edit.html' |
101 params['public_template'] = 'soc/host/public.html' |
106 params['public_template'] = 'soc/host/public.html' |
102 params['list_template'] = 'soc/models/list.html' |
107 params['list_template'] = 'soc/models/list.html' |
|
108 params['invite_template'] = 'soc/models/invite.html' |
103 |
109 |
104 params['lists_template'] = { |
110 params['lists_template'] = { |
105 'list_main': 'soc/list/list_main.html', |
111 'list_main': 'soc/list/list_main.html', |
106 'list_pagination': 'soc/list/list_pagination.html', |
112 'list_pagination': 'soc/list/list_pagination.html', |
107 'list_row': 'soc/host/list/host_row.html', |
113 'list_row': 'soc/host/list/host_row.html', |
108 'list_heading': 'soc/host/list/host_heading.html', |
114 'list_heading': 'soc/host/list/host_heading.html', |
109 } |
115 } |
110 |
116 |
111 params['delete_redirect'] = '/host/list' |
117 params['delete_redirect'] = '/host/list' |
112 params['invite_redirect'] = '/host/list' |
118 params['invite_redirect'] = '/request/list' |
113 |
119 |
114 params['save_message'] = [ugettext_lazy('Profile saved.')] |
120 params['save_message'] = [ugettext_lazy('Profile saved.')] |
115 |
121 |
116 params['edit_params'] = { |
122 params['edit_params'] = { |
117 self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED, |
123 self.DEF_SUBMIT_MSG_PARAM_NAME: self.DEF_SUBMIT_MSG_PROFILE_SAVED, |
121 rights['delete'] = [helper.access.checkIsDeveloper] |
127 rights['delete'] = [helper.access.checkIsDeveloper] |
122 |
128 |
123 params = dicts.merge(original_params, params) |
129 params = dicts.merge(original_params, params) |
124 rights = dicts.merge(original_rights, rights) |
130 rights = dicts.merge(original_rights, rights) |
125 |
131 |
126 base.View.__init__(self, rights=rights, params=params) |
132 role.RoleView.__init__(self, original_rights=rights, original_params=params) |
127 |
|
128 def _editPost(self, request, entity, fields): |
|
129 """See base.View._editPost(). |
|
130 """ |
|
131 |
|
132 fields['sponsor_ln'] = fields['sponsor'].link_name |
|
133 fields['user_ln'] = fields['user'].link_name |
|
134 |
133 |
135 |
134 |
136 view = View() |
135 view = View() |
137 |
136 |
138 create = view.create |
137 create = view.create |