app/soc/views/models/sponsor.py
changeset 387 c55195361cb6
parent 363 d35ffa6ca643
child 389 9b873166d7d5
equal deleted inserted replaced
386:33942ff6e71b 387:c55195361cb6
    26 from google.appengine.api import users
    26 from google.appengine.api import users
    27 
    27 
    28 from django import forms
    28 from django import forms
    29 from django.utils.translation import ugettext_lazy
    29 from django.utils.translation import ugettext_lazy
    30 
    30 
       
    31 from soc.logic import dicts
    31 from soc.logic import validate 
    32 from soc.logic import validate 
    32 from soc.views import helper
    33 from soc.views import helper
    33 from soc.views.helper import widgets
    34 from soc.views.helper import widgets
    34 from soc.views.models import base
    35 from soc.views.models import base
    35 
    36 
    78 
    79 
    79 class View(base.View):
    80 class View(base.View):
    80   """View methods for the Sponsor model
    81   """View methods for the Sponsor model
    81   """
    82   """
    82 
    83 
       
    84   SUBMIT_MSG_PROFILE_SAVED = 0
       
    85 
    83   def __init__(self, original_params=None, original_rights=None):
    86   def __init__(self, original_params=None, original_rights=None):
    84     """Defines the fields and methods required for the base View class
    87     """Defines the fields and methods required for the base View class
    85     to provide the user with list, public, create, edit and delete views.
    88     to provide the user with list, public, create, edit and delete views.
    86 
    89 
    87     Params:
    90     Params:
    88       original_params: a dict with params for this View 
    91       original_params: a dict with params for this View 
    89       original_rights: a dict with right definitions for this View
    92       original_rights: a dict with right definitions for this View
    90     """
    93     """    
    91 
    94 
    92     self.DEF_SUBMIT_MSG_PARAM_NAME = 's'
       
    93     self.SUBMIT_MSG_PROFILE_SAVED = 0
       
    94     #TODO(TLarsen) Better way to do this?
       
    95     
       
    96     self._logic = soc.logic.models.sponsor.logic
    95     self._logic = soc.logic.models.sponsor.logic
    97     
    96     
    98     params = {}
    97     params = {}
    99     rights = {}
    98     rights = {}
   100 
    99 
   101     params['name'] = "Sponsor"
   100     params['name'] = "Sponsor"
       
   101     params['name_short'] = "Sponsor"
   102     params['name_plural'] = "Sponsors"
   102     params['name_plural'] = "Sponsors"
   103        
   103        
   104     params['edit_form'] = EditForm
   104     params['edit_form'] = EditForm
   105     params['create_form'] = CreateForm
   105     params['create_form'] = CreateForm
   106 
   106 
   107     # TODO(SRabbelier) Add support for Django style template lookup
   107     # TODO(tlarsen) Add support for Django style template lookup
   108     params['create_template'] = 'soc/site/sponsor/profile/edit.html'
   108     params['edit_template'] = 'soc/site/sponsor/profile/edit.html'
   109     params['public_template'] = 'soc/group/profile/public.html'
   109     params['public_template'] = 'soc/group/profile/public.html'
   110 
       
   111     params['list_template'] = 'soc/group/list/all.html'
   110     params['list_template'] = 'soc/group/list/all.html'
   112 
   111 
   113     params['lists_template'] = {
   112     params['lists_template'] = {
   114       'list_main': 'soc/list/list_main.html',
   113       'list_main': 'soc/list/list_main.html',
   115       'list_pagination': 'soc/list/list_pagination.html',
   114       'list_pagination': 'soc/list/list_pagination.html',
   118     }
   117     }
   119     
   118     
   120     params['delete_redirect'] = '/site/sponsor/list'
   119     params['delete_redirect'] = '/site/sponsor/list'
   121     params['create_redirect'] = '/site/sponsor/profile'
   120     params['create_redirect'] = '/site/sponsor/profile'
   122     
   121     
   123     params['save_message'] = [ ugettext_lazy('Profile saved.') ]
   122     params['save_message'] = [ugettext_lazy('Profile saved.')]
   124     
   123     
   125     params['edit_params'] = {
   124     params['edit_params'] = {
   126         self.DEF_SUBMIT_MSG_PARAM_NAME:self.SUBMIT_MSG_PROFILE_SAVED,
   125         DEF_SUBMIT_MSG_PARAM_NAME: SUBMIT_MSG_PROFILE_SAVED,
   127         }
   126         }
   128     
   127     
   129     rights['list'] = [helper.access.checkIsDeveloper]
   128     rights['list'] = [helper.access.checkIsDeveloper]
   130     rights['delete'] = [helper.access.checkIsDeveloper]
   129     rights['delete'] = [helper.access.checkIsDeveloper]
   131 
   130 
   132     params = soc.logic.dicts.mergeDicts(original_params, params)
   131     params = dicts.merge(original_params, params)
   133     rights = soc.logic.dicts.mergeDicts(original_rights, rights)
   132     rights = dicts.merge(original_rights, rights)
   134     
   133     
   135     base.View.__init__(self, rights=rights, params=params)
   134     base.View.__init__(self, rights=rights, params=params)
   136 
   135 
   137   def _editPost(self, request, entity, fields):
   136   def _editPost(self, request, entity, fields):
   138     """
   137     """