# HG changeset patch # User Pawel Solyga # Date 1226960462 0 # Node ID e1e24c0a4e8273eac1c87fd68f65f04a853d53a6 # Parent be89bf307478aea6eb8944383d0e47dcba53d66b Add new parameters to views: url_name which is name used in urls (instead of using lower entity names) and module_name which is used for constructing django urls. Append changes to all affected files. Fix some title names. Change urls that included underscores like "site_settings" into urls with slash "site/settings". Plus some other minor fixes. Patch by: Pawel Solyga diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/home_settings/error.html --- a/app/soc/templates/soc/home_settings/error.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/home_settings/error.html Mon Nov 17 22:21:02 2008 +0000 @@ -22,5 +22,5 @@ {% endblock %} {% block body %} -This is the default home page, which can be edited via the Home Settings.
+This is the default home page, which can be edited via the Home Settings.
{% endblock %} diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/home_settings/list/home_row.html --- a/app/soc/templates/soc/home_settings/list/home_row.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/home_settings/list/home_row.html Mon Nov 17 22:21:02 2008 +0000 @@ -1,9 +1,9 @@ +onclick="document.location.href='/home/settings/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
{{ data_element.partial_path}}/{{ data_element.link_name }} + href="/home/settings/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}
diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/home_settings/public.html --- a/app/soc/templates/soc/home_settings/public.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/home_settings/public.html Mon Nov 17 22:21:02 2008 +0000 @@ -18,10 +18,10 @@ creating a new Document or editing an existing Document and then selecting that Document in the -Site Settings interface. +Site Settings interface. Other elements of this page, such as a feed to be displayed below this content, can also be set using the -Site Settings interface. +Site Settings interface. You need to sign in as site Developer in order to change -Site Settings. +Site Settings. {% endblock %} diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/models/edit.html --- a/app/soc/templates/soc/models/edit.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/models/edit.html Mon Nov 17 22:21:02 2008 +0000 @@ -20,7 +20,7 @@ {{ page_name }} {% if entity %} - (Public page) + (Public page) {% endif %} {% endblock %} @@ -49,7 +49,7 @@ {% if entity %} - + {% endif %} {% endblock %} diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/site_settings/list/site_row.html --- a/app/soc/templates/soc/site_settings/list/site_row.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/site_settings/list/site_row.html Mon Nov 17 22:21:02 2008 +0000 @@ -1,9 +1,9 @@ +onclick="document.location.href='/site/settings/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}'" name="name">
{{ data_element.partial_path}}/{{ data_element.link_name }} + href="/site/settings/edit/{{ data_element.partial_path }}/{{ data_element.link_name }}">{{ data_element.partial_path}}/{{ data_element.link_name }}
diff -r be89bf307478 -r e1e24c0a4e82 app/soc/templates/soc/user/list/user_row.html --- a/app/soc/templates/soc/user/list/user_row.html Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/templates/soc/user/list/user_row.html Mon Nov 17 22:21:02 2008 +0000 @@ -1,7 +1,7 @@ +onclick="document.location.href='{{redirect_action|lower}}/{{ data_element.link_name }}'" name="name">
{{ data_element.account }} + href="{{redirect_action|lower}}/{{ data_element.link_name }}">{{ data_element.account }}
{{ data_element.account.email }}
diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/base.py --- a/app/soc/views/models/base.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/base.py Mon Nov 17 22:21:02 2008 +0000 @@ -54,7 +54,7 @@ DEF_SUBMIT_MSG_PROFILE_SAVED = 0 DEF_CREATE_NEW_ENTITY_MSG = ugettext_lazy( - ' You can create a new %(entity_type_lower)s by visiting' + ' You can create a new %(entity_type)s by visiting' ' Create ' 'a New %(entity_type)s page.') @@ -69,6 +69,7 @@ name: the name of the entity (names should have sentence-style caps) name_short: the short form name of the name ('org' vs 'organization') name_plural: the plural form of the name + url_name: the name of the entity used in urls edit_form: the class of the Django form to be used when editing create_form: the class of the Django form to be used when creating edit_template: the Django template to be used for editing @@ -87,9 +88,9 @@ new_rights['any_access'] = [access.checkIsUser] new_params = {} - new_params['create_redirect'] = '/%s' % params['name_short'].lower() - new_params['missing_redirect'] = '/%s/create' % params['name_short'].lower() - + new_params['create_redirect'] = '/%s' % params['url_name'] + new_params['missing_redirect'] = '/%s/create' % params['url_name'] + new_params['sidebar'] = None new_params['sidebar_defaults'] = [ ('/%s/create', 'New %(name)s'), @@ -101,21 +102,21 @@ new_params['django_patterns'] = None new_params['django_patterns_defaults'] = [ - (r'^%(name_lower)s/show/%(key_fields)s$', + (r'^%(url_name)s/show/%(key_fields)s$', 'soc.views.models.%s.public', 'Show %(name)s'), - (r'^%(name_lower)s/create$', + (r'^%(url_name)s/create$', 'soc.views.models.%s.create', 'Create %(name)s'), - (r'^%(name_lower)s/create/%(key_fields)s$', + (r'^%(url_name)s/create/%(key_fields)s$', 'soc.views.models.%s.create', 'Create %(name)s'), - (r'^%(name_lower)s/delete/%(key_fields)s$', + (r'^%(url_name)s/delete/%(key_fields)s$', 'soc.views.models.%s.delete', 'Delete %(name)s'), - (r'^%(name_lower)s/edit/%(key_fields)s$', + (r'^%(url_name)s/edit/%(key_fields)s$', 'soc.views.models.%s.edit', 'Edit %(name)s'), - (r'^%(name_lower)s/list$', + (r'^%(url_name)s/list$', 'soc.views.models.%s.list', 'List %(name_plural)s'), ] - new_params['list_redirect_action'] = params['name_short'] + '/edit' + new_params['list_redirect_action'] = '/' + params['url_name'] + '/edit' self._rights = dicts.merge(rights, new_rights) self._params = dicts.merge(params, new_params) @@ -463,6 +464,7 @@ context['entity_type'] = params['name'] context['entity_type_plural'] = params['name_plural'] context['entity_type_short'] = params['name_short'] + context['entity_type_url'] = params['url_name'] template = params['edit_template'] @@ -541,7 +543,7 @@ result = [] for url, title in defaults: - url = url % params['name_short'].lower() + url = url % params['url_name'].lower() title = title % { 'name': params['name'], @@ -595,18 +597,18 @@ patterns = [] for url, module, name in default_patterns: - name_short_lower = params['name_short'].lower() - name_plural_lower = params['name_plural'].lower() + name_short = params['name_short'] + name_plural = params['name_plural'] name = name % { - 'name': name_short_lower, - 'name_plural': name_plural_lower, + 'name': name_short, + 'name_plural': name_plural, } - module = module % name_short_lower + module = module % params['module_name'] url = url % { - 'name_lower': name_short_lower, + 'url_name': params['url_name'], 'lnp': path_link_name.LINKNAME_ARG_PATTERN, 'ulnp': path_link_name.LINKNAME_PATTERN_CORE, 'key_fields': key_fields_pattern, diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/document.py --- a/app/soc/views/models/document.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/document.py Mon Nov 17 22:21:02 2008 +0000 @@ -99,6 +99,8 @@ params['name'] = "Document" params['name_short'] = "Document" params['name_plural'] = "Documents" + params['url_name'] = "document" + params['module_name'] = "document" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -115,7 +117,7 @@ 'list_heading': 'soc/document/list/docs_heading.html', } - params['delete_redirect'] = '/document/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' params['save_message'] = [ugettext_lazy('Profile saved.')] diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/home_settings.py --- a/app/soc/views/models/home_settings.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/home_settings.py Mon Nov 17 22:21:02 2008 +0000 @@ -51,14 +51,14 @@ # TODO(tlarsen): partial_path will be a hard-coded read-only # field for some (most?) User Roles doc_partial_path = forms.CharField(required=False, - label=soc.models.work.Work.partial_path.verbose_name, + label=ugettext_lazy('Document partial path'), help_text=soc.models.work.Work.partial_path.help_text) # TODO(tlarsen): actually, using these two text fields to specify # the Document is pretty cheesy; this needs to be some much better # Role-scoped Document selector that we don't have yet doc_link_name = forms.CharField(required=False, - label=soc.models.work.Work.link_name.verbose_name, + label=ugettext_lazy('Document link name'), help_text=soc.models.work.Work.link_name.help_text) def clean_feed_url(self): @@ -112,8 +112,10 @@ rights = {} params['name'] = "Home Settings" - params['name_short'] = "home_settings" + params['name_short'] = "Home Settings" params['name_plural'] = "Home Settings" + params['url_name'] = "home/settings" + params['module_name'] = "home_settings" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -130,7 +132,7 @@ 'list_heading': 'soc/home_settings/list/home_heading.html', } - params['delete_redirect'] = '/home/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' params['save_message'] = [ugettext_lazy('Profile saved.')] diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/host.py --- a/app/soc/views/models/host.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/host.py Mon Nov 17 22:21:02 2008 +0000 @@ -97,6 +97,8 @@ params['name'] = "Host" params['name_short'] = "Host" params['name_plural'] = "Hosts" + params['url_name'] = "host" + params['module_name'] = "host" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -114,7 +116,7 @@ 'list_heading': 'soc/host/list/host_heading.html', } - params['delete_redirect'] = '/host/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' params['invite_redirect'] = '/request/list' params['save_message'] = [ugettext_lazy('Profile saved.')] diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/request.py --- a/app/soc/views/models/request.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/request.py Mon Nov 17 22:21:02 2008 +0000 @@ -105,6 +105,8 @@ params['name'] = "Request" params['name_short'] = "Request" params['name_plural'] = "Requests" + params['url_name'] = "request" + params['module_name'] = "request" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -123,8 +125,8 @@ params['sidebar_defaults'] = [('/%s/list', 'List %(plural)s')] - params['delete_redirect'] = '/request/list' - params['create_redirect'] = '/request' + params['delete_redirect'] = '/' + params['url_name'] + '/list' + params['create_redirect'] = '/'.join(params['url_name']) params['save_message'] = [ugettext_lazy('Request saved.')] diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/role.py --- a/app/soc/views/models/role.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/role.py Mon Nov 17 22:21:02 2008 +0000 @@ -91,9 +91,8 @@ new_params = {} new_params['list_template'] = 'soc/models/create_invite.html' - new_params['list_redirect_action'] = 'request/create/%s/%s' % ( - self._params['name_short'].lower(), - kwargs['link_name']) + new_params['list_redirect_action'] = '/request/create/%s/%s' % ( + self._params['url_name'], kwargs['link_name']) new_params['list_redirect_entity'] = self._params['name'] new_params['name'] = self._params['name'] new_params['name_short'] = self._params['name_short'] @@ -189,7 +188,7 @@ params = {} default_patterns = self._params['django_patterns_defaults'] default_patterns += [ - (r'^%(name_lower)s/invite/%(lnp)s$', + (r'^%(url_name)s/invite/%(lnp)s$', 'soc.views.models.%s.invite', 'Invite %(name)s')] params['django_patterns_defaults'] = default_patterns diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/site_settings.py --- a/app/soc/views/models/site_settings.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/site_settings.py Mon Nov 17 22:21:02 2008 +0000 @@ -82,9 +82,14 @@ params = {} rights = {} + # add ugettext_lazy ? params['name'] = "Site Settings" - params['name_short'] = "site_settings" + params['name_short'] = "Site Settings" params['name_plural'] = "Site Settings" + # lower name and replace " " with "/" + # for module name lower name and replace " " with "_" + params['url_name'] = "site/settings" + params['module_name'] = "site_settings" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -96,9 +101,9 @@ 'list_heading': 'soc/site_settings/list/site_heading.html', } - params['delete_redirect'] = '/site/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' - params['sidebar_additional'] = [('/site_settings/edit','Edit Main Site Settings')] + params['sidebar_additional'] = [ ( '/' + params['url_name'] + '/edit', 'Edit Main Site Settings')] params = dicts.merge(original_params, params) rights = dicts.merge(original_rights, rights) @@ -143,7 +148,7 @@ patterns = super(View, self).getDjangoURLPatterns() patterns += [(r'^$','soc.views.models.site_settings.main_public')] - patterns += [(r'^site_settings/edit$', 'soc.views.models.site_settings.main_edit')] + patterns += [(r'^' + self._params['url_name'] + '/edit$', 'soc.views.models.site_settings.main_edit')] return patterns view = View() diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/sponsor.py --- a/app/soc/views/models/sponsor.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/sponsor.py Mon Nov 17 22:21:02 2008 +0000 @@ -99,11 +99,16 @@ params['name'] = "Sponsor" params['name_short'] = "Sponsor" params['name_plural'] = "Sponsors" + # TODO(pawel.solyga): create url_name and module_name automatically + # from name. Make that work for all other Views too. Hopefully + # solution that will be implemented in base View. + params['url_name'] = "sponsor" + params['module_name'] = "sponsor" params['edit_form'] = EditForm params['create_form'] = CreateForm - # TODO(tlarsen) Add support for Django style template lookup + # TODO(tlarsen): Add support for Django style template lookup params['edit_template'] = 'soc/sponsor/edit.html' params['public_template'] = 'soc/group/public.html' params['list_template'] = 'soc/models/list.html' @@ -115,7 +120,7 @@ 'list_heading': 'soc/group/list/group_heading.html', } - params['delete_redirect'] = '/sponsor/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' params['save_message'] = [ugettext_lazy('Profile saved.')] diff -r be89bf307478 -r e1e24c0a4e82 app/soc/views/models/user.py --- a/app/soc/views/models/user.py Mon Nov 17 22:12:34 2008 +0000 +++ b/app/soc/views/models/user.py Mon Nov 17 22:21:02 2008 +0000 @@ -127,6 +127,8 @@ params['name'] = "User" params['name_short'] = "User" params['name_plural'] = "Users" + params['url_name'] = "user" + params['module_name'] = "user" params['edit_form'] = EditForm params['create_form'] = CreateForm @@ -143,7 +145,7 @@ 'list_heading': 'soc/user/list/user_heading.html', } - params['delete_redirect'] = '/user/list' + params['delete_redirect'] = '/' + params['url_name'] + '/list' params['save_message'] = [ugettext_lazy('Profile saved.')] @@ -199,8 +201,8 @@ params = {} params['name'] = "User (self)" params['sidebar'] = [ - ('/user/edit', 'Profile'), - ('/roles/list', 'Roles'), + ('/' + self._params['url_name'] + '/edit', 'Profile'), + ('/' + self._params['url_name'] + '/roles', 'Roles'), ] return self.getSidebarLinks(params) @@ -209,7 +211,7 @@ """ patterns = super(View, self).getDjangoURLPatterns() - patterns += [(r'^user/edit$','soc.views.user.profile.create')] + patterns += [(r'^' + self._params['url_name'] + '/edit$','soc.views.user.profile.create')] return patterns