36 |
36 |
37 from soc.logic import cleaning |
37 from soc.logic import cleaning |
38 from soc.logic import dicts |
38 from soc.logic import dicts |
39 from soc.logic import models as model_logic |
39 from soc.logic import models as model_logic |
40 from soc.logic.models.user import logic as user_logic |
40 from soc.logic.models.user import logic as user_logic |
|
41 from soc.logic.models.site import logic as site_logic |
41 from soc.views import helper |
42 from soc.views import helper |
42 from soc.views.helper import access |
43 from soc.views.helper import access |
43 from soc.views.helper import decorators |
44 from soc.views.helper import decorators |
44 from soc.views.helper import dynaform |
45 from soc.views.helper import dynaform |
45 from soc.views.helper import redirects |
46 from soc.views.helper import redirects |
54 class View(base.View): |
55 class View(base.View): |
55 """Views for User own profiles. |
56 """Views for User own profiles. |
56 """ |
57 """ |
57 |
58 |
58 DEF_ROLE_LIST_MSG_FMT = ugettext("Your roles as %(name)s.") |
59 DEF_ROLE_LIST_MSG_FMT = ugettext("Your roles as %(name)s.") |
|
60 DEF_NO_ROLES_MSG_FMT = ugettext("You don't have any Roles in %s.") |
59 |
61 |
60 def __init__(self, params=None): |
62 def __init__(self, params=None): |
61 """Defines the fields and methods required for the base View class |
63 """Defines the fields and methods required for the base View class |
62 to provide the user with list, public, create, edit and delete views. |
64 to provide the user with list, public, create, edit and delete views. |
63 |
65 |
243 contents = [] |
245 contents = [] |
244 |
246 |
245 i = 0 |
247 i = 0 |
246 |
248 |
247 for name, view in sorted(role_view.ROLE_VIEWS.iteritems()): |
249 for name, view in sorted(role_view.ROLE_VIEWS.iteritems()): |
248 params = view.getParams().copy() |
250 list_params = view.getParams().copy() |
249 params['list_action'] = (redirects.getEditRedirect, params) |
251 list_params['list_action'] = (redirects.getEditRedirect, params) |
250 params['list_description'] = self.DEF_ROLE_LIST_MSG_FMT % params |
252 list_params['list_description'] = self.DEF_ROLE_LIST_MSG_FMT % params |
251 |
253 |
252 list = helper.lists.getListContent(request, params, filter, i) |
254 list = helper.lists.getListContent(request, list_params, filter, i, True) |
253 contents.append(list) |
255 |
254 i += 1 |
256 if list: |
|
257 contents.append(list) |
|
258 i += 1 |
|
259 |
|
260 site = site_logic.getSingleton() |
|
261 site_name = site.site_name |
|
262 |
|
263 params = params.copy() |
|
264 params['no_lists_msg'] = self.DEF_NO_ROLES_MSG_FMT % site_name |
255 |
265 |
256 return self._list(request, params, contents, page_name) |
266 return self._list(request, params, contents, page_name) |
257 |
267 |
258 def getSidebarMenus(self, id, user, params=None): |
268 def getSidebarMenus(self, id, user, params=None): |
259 """See base.View.getSidebarMenus(). |
269 """See base.View.getSidebarMenus(). |