app/soc/views/models/base.py
changeset 471 dcb1f7821b39
parent 459 2cfcedaf7c16
child 482 839740b061ad
equal deleted inserted replaced
470:7ba510d3fad3 471:dcb1f7821b39
    17 """Helpers functions for displaying views.
    17 """Helpers functions for displaying views.
    18 """
    18 """
    19 
    19 
    20 __authors__ = [
    20 __authors__ = [
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
    21   '"Sverre Rabbelier" <sverre@rabbelier.nl>',
       
    22   '"Pawel Solyga" <pawel.solyga@gmail.com>',
    22   ]
    23   ]
    23 
    24 
    24 
    25 
    25 from django import http
    26 from django import http
    26 from django.utils.translation import ugettext_lazy
    27 from django.utils.translation import ugettext_lazy
    53   DEF_CREATE_NEW_ENTITY_MSG = ugettext_lazy(
    54   DEF_CREATE_NEW_ENTITY_MSG = ugettext_lazy(
    54       ' You can create a new %(entity_type_lower)s by visiting'
    55       ' You can create a new %(entity_type_lower)s by visiting'
    55       ' <a href="%(create)s">Create '
    56       ' <a href="%(create)s">Create '
    56       'a New %(entity_type)s</a> page.')
    57       'a New %(entity_type)s</a> page.')
    57 
    58 
    58   def __init__(self, params=None, rights=None, stop=False):
    59   def __init__(self, params=None, rights=None):
    59     """
    60     """
    60 
    61 
    61     Args:
    62     Args:
    62       rights: This dictionary should be filled with the access check
    63       rights: This dictionary should be filled with the access check
    63         functions that should be called, it will be modified in-place.
    64         functions that should be called, it will be modified in-place.
    89 
    90 
    90     Args:
    91     Args:
    91       request: the standard Django HTTP request object
    92       request: the standard Django HTTP request object
    92       page: a soc.logic.site.page.Page object which is abstraction
    93       page: a soc.logic.site.page.Page object which is abstraction
    93         that combines a Django view with sidebar menu info
    94         that combines a Django view with sidebar menu info
       
    95       params: a dict with params for this View
    94       kwargs: the Key Fields for the specified entity
    96       kwargs: the Key Fields for the specified entity
    95     """
    97     """
    96 
    98 
    97     params = dicts.merge(params, self._params)
    99     params = dicts.merge(params, self._params)
    98 
   100 
   131 
   133 
   132     Args:
   134     Args:
   133       request: the standard Django HTTP request object
   135       request: the standard Django HTTP request object
   134       page: a soc.logic.site.page.Page object which is abstraction
   136       page: a soc.logic.site.page.Page object which is abstraction
   135         that combines a Django view with sidebar menu info
   137         that combines a Django view with sidebar menu info
       
   138       params: a dict with params for this View
   136       kwargs: not used for create()
   139       kwargs: not used for create()
   137     """
   140     """
   138 
   141 
   139     # Create page is an edit page with no key fields
   142     # Create page is an edit page with no key fields
   140     kwargs = {}
   143     kwargs = {}
   149                                                  new_suffix='edit')
   152                                                  new_suffix='edit')
   150 
   153 
   151     return self.edit(request, page=page, params=params, **kwargs)
   154     return self.edit(request, page=page, params=params, **kwargs)
   152 
   155 
   153   def edit(self, request, page=None, params=None, **kwargs):
   156   def edit(self, request, page=None, params=None, **kwargs):
   154     """Displays the public page for the entity specified by **kwargs
   157     """Displays the edit page for the entity specified by **kwargs
   155 
   158 
   156     Args:
   159     Args:
   157       request: the standard Django HTTP request object
   160       request: the standard Django HTTP request object
   158       page: a soc.logic.site.page.Page object which is abstraction
   161       page: a soc.logic.site.page.Page object which is abstraction
   159         that combines a Django view with sidebar menu info
   162         that combines a Django view with sidebar menu info
       
   163       params: a dict with params for this View
   160       kwargs: The Key Fields for the specified entity
   164       kwargs: The Key Fields for the specified entity
   161     """
   165     """
   162 
   166 
   163     params = dicts.merge(params, self._params)
   167     params = dicts.merge(params, self._params)
   164 
   168 
   263     
   267     
   264     Args:
   268     Args:
   265       request: the standard Django HTTP request object
   269       request: the standard Django HTTP request object
   266       page: a soc.logic.site.page.Page object which is abstraction
   270       page: a soc.logic.site.page.Page object which is abstraction
   267         that combines a Django view with sidebar menu info
   271         that combines a Django view with sidebar menu info
       
   272       params: a dict with params for this View
   268     """
   273     """
   269 
   274 
   270     params = dicts.merge(params, self._params)
   275     params = dicts.merge(params, self._params)
   271 
   276 
   272     try:
   277     try:
   302 
   307 
   303     Args:
   308     Args:
   304       request: the standard Django HTTP request object
   309       request: the standard Django HTTP request object
   305       page: a soc.logic.site.page.Page object which is abstraction
   310       page: a soc.logic.site.page.Page object which is abstraction
   306         that combines a Django view with sidebar menu info
   311         that combines a Django view with sidebar menu info
       
   312       params: a dict with params for this View
   307       kwargs: The Key Fields for the specified entity
   313       kwargs: The Key Fields for the specified entity
   308     """
   314     """
   309 
   315 
   310     params = dicts.merge(params, self._params)
   316     params = dicts.merge(params, self._params)
   311 
   317 
   394     Args:
   400     Args:
   395       request: the django request object
   401       request: the django request object
   396       entity: the entity that is used
   402       entity: the entity that is used
   397       context: the context to be used
   403       context: the context to be used
   398       form: the form that will be used
   404       form: the form that will be used
       
   405       params: a dict with params for this View
   399     """
   406     """
   400 
   407 
   401     suffix = self._logic.getKeySuffix(entity)
   408     suffix = self._logic.getKeySuffix(entity)
   402 
   409 
   403     context['form'] = form
   410     context['form'] = form