# HG changeset patch # User Sverre Rabbelier # Date 1228339621 0 # Node ID a76f1b443ea43e8948b31e07d506c045565ee682 # Parent 9635cbaa2dcd2a1d2843b554d4d535bd3ff1dd9c Cleanups in the views module Mainly rename from original_params to new_params (so that the keyword argument in the __init__ method is the same for all). Also use super(View, self) where appropriate. Patch by: Sverre Rabbelier diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/document.py --- a/app/soc/views/models/document.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/document.py Wed Dec 03 21:27:01 2008 +0000 @@ -85,29 +85,29 @@ """View methods for the Document model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.document.logic + new_params = {} + new_params['logic'] = soc.logic.models.document.logic - params['name'] = "Document" - params['name_short'] = "Document" - params['name_plural'] = "Documents" - params['url_name'] = "document" - params['module_name'] = "document" + new_params['name'] = "Document" + new_params['name_short'] = "Document" + new_params['name_plural'] = "Documents" + new_params['url_name'] = "document" + new_params['module_name'] = "document" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def _editPost(self, request, entity, fields): """See base.View._editPost(). diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/host.py --- a/app/soc/views/models/host.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/host.py Wed Dec 03 21:27:01 2008 +0000 @@ -76,35 +76,35 @@ """View methods for the Host model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ rights = {} rights['edit'] = [access.checkIsInvited] - params = {} - params['rights'] = rights - params['logic'] = soc.logic.models.host.logic + new_params = {} + new_params['rights'] = rights + new_params['logic'] = soc.logic.models.host.logic - params['logic'] = soc.logic.models.host.logic - params['group_view'] = soc.views.models.sponsor.view - params['invite_filter'] = {'group_ln': 'link_id'} + new_params['logic'] = soc.logic.models.host.logic + new_params['group_view'] = soc.views.models.sponsor.view + new_params['invite_filter'] = {'group_ln': 'link_id'} - params['name'] = "Host" - params['name_short'] = "Host" - params['name_plural'] = "Hosts" - params['url_name'] = "host" - params['module_name'] = "host" + new_params['name'] = "Host" + new_params['name_short'] = "Host" + new_params['name_plural'] = "Hosts" + new_params['url_name'] = "host" + new_params['module_name'] = "host" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) role.RoleView.__init__(self, params=params) diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/presence.py --- a/app/soc/views/models/presence.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/presence.py Wed Dec 03 21:27:01 2008 +0000 @@ -97,32 +97,32 @@ """View methods for the Document model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.presence.logic + new_params = {} + new_params['logic'] = soc.logic.models.presence.logic - params['name'] = "Home Settings" - params['name_short'] = "Home Settings" - params['name_plural'] = "Home Settings" - params['url_name'] = "home/settings" - params['module_name'] = "presence" + new_params['name'] = "Home Settings" + new_params['name_short'] = "Home Settings" + new_params['name_plural'] = "Home Settings" + new_params['url_name'] = "home/settings" + new_params['module_name'] = "presence" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm # Disable the presence sidebar until we have some use for it - params['sidebar_defaults'] = [] + new_params['sidebar_defaults'] = [] - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def _public(self, request, entity, context): """ diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/program.py --- a/app/soc/views/models/program.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/program.py Wed Dec 03 21:27:01 2008 +0000 @@ -42,25 +42,25 @@ """View methods for the Sponsor model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.program.logic + new_params = {} + new_params['logic'] = soc.logic.models.program.logic - params['name'] = "Program" - params['name_short'] = "Program" - params['name_plural'] = "Programs" - params['url_name'] = "program" - params['module_name'] = "program" + new_params['name'] = "Program" + new_params['name_short'] = "Program" + new_params['name_plural'] = "Programs" + new_params['url_name'] = "program" + new_params['module_name'] = "program" - params['extra_dynaexclude'] = ['home'] - params['create_extra_dynafields'] = { + new_params['extra_dynaexclude'] = ['home'] + new_params['create_extra_dynafields'] = { 'description': forms.fields.CharField(widget=helper.widgets.TinyMCE( attrs={'rows':10, 'cols':40})), 'scope_path': forms.CharField(widget=forms.HiddenInput, @@ -68,9 +68,9 @@ 'clean_link_id': cleaning.clean_link_id, } - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def create(self, request, **kwargs): """Specialized create view to enforce needing a scope_path diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/request.py --- a/app/soc/views/models/request.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/request.py Wed Dec 03 21:27:01 2008 +0000 @@ -93,40 +93,37 @@ """View methods for the Docs model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ rights = {} rights['listSelf'] = [access.checkIsUser] - params = {} - params['rights'] = rights - params['logic'] = soc.logic.models.request.logic + new_params = {} + new_params['rights'] = rights + new_params['logic'] = soc.logic.models.request.logic - params['name'] = "Request" - params['name_short'] = "Request" - params['name_plural'] = "Requests" - params['url_name'] = "request" - params['module_name'] = "request" + new_params['name'] = "Request" + new_params['name_short'] = "Request" + new_params['name_plural'] = "Requests" + new_params['url_name'] = "request" + new_params['module_name'] = "request" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm - params['sidebar_defaults'] = [('/%s/list', 'List %(name_plural)s', 'list')] + new_params['sidebar_defaults'] = [('/%s/list', 'List %(name_plural)s', 'list')] - params['delete_redirect'] = '/' + params['url_name'] + '/list' - params['create_redirect'] = '/' + params['url_name'] + new_params['save_message'] = [ugettext_lazy('Request saved.')] - params['save_message'] = [ugettext_lazy('Request saved.')] + params = dicts.merge(params, new_params) - params = dicts.merge(original_params, params) - - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def listSelf(self, request, page_name=None, params=None, **kwargs): diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/role.py --- a/app/soc/views/models/role.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/role.py Wed Dec 03 21:27:01 2008 +0000 @@ -77,10 +77,10 @@ """ Args: - original_params: This dictionary should be filled with the parameters + params: This dictionary should be filled with the parameters """ - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def create(self, request, **kwargs): """Specialized create view to enforce needing a scope_path diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/site.py --- a/app/soc/views/models/site.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/site.py Wed Dec 03 21:27:01 2008 +0000 @@ -62,42 +62,42 @@ """View methods for the Document model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.site.logic + new_params = {} + new_params['logic'] = soc.logic.models.site.logic # TODO(alturin): add ugettext_lazy ? - params['name'] = "Site Settings" - params['name_short'] = "Site" - params['name_plural'] = "Site Settings" + new_params['name'] = "Site Settings" + new_params['name_short'] = "Site" + new_params['name_plural'] = "Site Settings" # lower name and replace " " with "/" - params['url_name'] = "site/settings" - params['module_name'] = "site" + new_params['url_name'] = "site/settings" + new_params['module_name'] = "site" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm - params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')] - params['sidebar_heading'] = params['name_short'] + new_params['sidebar_defaults'] = [('/%s/edit', 'Edit %(name)s', 'edit')] + new_params['sidebar_heading'] = new_params['name_short'] - params['public_template'] = 'soc/home/public.html' + new_params['public_template'] = 'soc/home/public.html' - params['rights'] = { + new_params['rights'] = { 'unspecified': [access.checkIsDeveloper], 'any_access': [access.allow], 'public': [access.allow] } - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - presence.View.__init__(self, original_params=params) + super(View, self).__init__(params=params) def mainPublic(self, request, page_name=None, **kwargs): """Displays the main site settings page. diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/sponsor.py --- a/app/soc/views/models/sponsor.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/sponsor.py Wed Dec 03 21:27:01 2008 +0000 @@ -43,41 +43,41 @@ """View methods for the Sponsor model. """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.sponsor.logic + new_params = {} + new_params['logic'] = soc.logic.models.sponsor.logic - params['name'] = "Sponsor" - params['name_short'] = "Sponsor" - params['name_plural'] = "Sponsors" + new_params['name'] = "Sponsor" + new_params['name_short'] = "Sponsor" + new_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" + new_params['url_name'] = "sponsor" + new_params['module_name'] = "sponsor" - params['extra_dynaexclude'] = ['founder', 'home'] - params['edit_extra_dynafields'] = { + new_params['extra_dynaexclude'] = ['founder', 'home'] + new_params['edit_extra_dynafields'] = { 'founded_by': forms.CharField(widget=helper.widgets.ReadOnlyInput(), required=False), } # TODO(tlarsen): Add support for Django style template lookup - params['public_template'] = 'soc/group/public.html' + new_params['public_template'] = 'soc/group/public.html' - params['list_row'] = 'soc/group/list/row.html' - params['list_heading'] = 'soc/group/list/heading.html' + new_params['list_row'] = 'soc/group/list/row.html' + new_params['list_heading'] = 'soc/group/list/heading.html' - params = dicts.merge(original_params, params) - - base.View.__init__(self, params=params) + params = dicts.merge(params, new_params) + + super(View, self).__init__(params=params) def _editGet(self, request, entity, form): """See base.View._editGet(). diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/user.py --- a/app/soc/views/models/user.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/user.py Wed Dec 03 21:27:01 2008 +0000 @@ -114,33 +114,33 @@ """ - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ - params = {} - params['logic'] = soc.logic.models.user.logic + new_params = {} + new_params['logic'] = soc.logic.models.user.logic - params['name'] = "User" - params['name_short'] = "User" - params['name_plural'] = "Users" - params['url_name'] = "user" - params['module_name'] = "user" + new_params['name'] = "User" + new_params['name_short'] = "User" + new_params['name_plural'] = "Users" + new_params['url_name'] = "user" + new_params['module_name'] = "user" - params['edit_form'] = EditForm - params['create_form'] = CreateForm + new_params['edit_form'] = EditForm + new_params['create_form'] = CreateForm - params['edit_template'] = 'soc/user/edit.html' + new_params['edit_template'] = 'soc/user/edit.html' - params['sidebar_heading'] = 'Users' + new_params['sidebar_heading'] = 'Users' - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) def _editGet(self, request, entity, form): diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/models/user_self.py --- a/app/soc/views/models/user_self.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/models/user_self.py Wed Dec 03 21:27:01 2008 +0000 @@ -86,12 +86,12 @@ '
  • the account is a former account that cannot be used again
  • ' '') - def __init__(self, original_params=None): + 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: - original_params: a dict with params for this View + params: a dict with params for this View """ rights = {} @@ -101,21 +101,21 @@ rights['roles'] = [access.checkIsUser] rights['signIn'] = [access.checkNotLoggedIn] - params = {} - params['rights'] = rights - params['logic'] = soc.logic.models.user.logic + new_params = {} + new_params['rights'] = rights + new_params['logic'] = soc.logic.models.user.logic - params['name'] = "User" - params['name_short'] = "User" - params['name_plural'] = "Users" - params['url_name'] = "user" - params['module_name'] = "user_self" + new_params['name'] = "User" + new_params['name_short'] = "User" + new_params['name_plural'] = "Users" + new_params['url_name'] = "user" + new_params['module_name'] = "user_self" - params['sidebar_heading'] = 'Users' + new_params['sidebar_heading'] = 'Users' - params = dicts.merge(original_params, params) + params = dicts.merge(params, new_params) - base.View.__init__(self, params=params) + super(View, self).__init__(params=params) EDIT_SELF_TMPL = 'soc/user/edit_self.html' diff -r 9635cbaa2dcd -r a76f1b443ea4 app/soc/views/out_of_band.py --- a/app/soc/views/out_of_band.py Wed Dec 03 21:26:16 2008 +0000 +++ b/app/soc/views/out_of_band.py Wed Dec 03 21:27:01 2008 +0000 @@ -45,6 +45,7 @@ django.http.HttpResponse; the most commonly used is 'status' to set the HTTP status code for the response """ + self.message_fmt = message_fmt self.context = context self.response_args = response_args @@ -67,13 +68,15 @@ a default value of None, in which case self.DEF_LOGIN_MSG_FMT is used **response_args: see Error.__init__() """ + if not message_fmt: message_fmt = self.DEF_LOGIN_MSG_FMT - Error.__init__(self, message_fmt, **response_args) + super(LoginRequest, self).__init__(message_fmt, **response_args) class AccessViolation(Error): """"Out of band error raised when an access requirement was not met. """ + pass