app/soc/views/models/organization.py
changeset 2076 1cd180cc56c9
parent 2037 3f355dca3679
child 2093 987913140e31
equal deleted inserted replaced
2075:c6bdfd560d91 2076:1cd180cc56c9
    34 from soc.logic import accounts
    34 from soc.logic import accounts
    35 from soc.logic.models import mentor as mentor_logic
    35 from soc.logic.models import mentor as mentor_logic
    36 from soc.logic.models import organization as org_logic
    36 from soc.logic.models import organization as org_logic
    37 from soc.logic.models import org_admin as org_admin_logic
    37 from soc.logic.models import org_admin as org_admin_logic
    38 from soc.logic.models import org_app as org_app_logic
    38 from soc.logic.models import org_app as org_app_logic
    39 from soc.logic.models import program as program_logic
       
    40 from soc.logic.models import user as user_logic
    39 from soc.logic.models import user as user_logic
    41 from soc.views import helper
    40 from soc.views import helper
    42 from soc.views import out_of_band
    41 from soc.views import out_of_band
    43 from soc.views.helper import access
    42 from soc.views.helper import access
    44 from soc.views.helper import decorators
    43 from soc.views.helper import decorators
    45 from soc.views.helper import dynaform
    44 from soc.views.helper import dynaform
    46 from soc.views.helper import lists
    45 from soc.views.helper import lists
    47 from soc.views.helper import redirects
    46 from soc.views.helper import redirects
    48 from soc.views.helper import widgets
    47 from soc.views.helper import widgets
    49 from soc.views.models import group
    48 from soc.views.models import group
    50 from soc.views.models import program as program_view
       
    51 
    49 
    52 import soc.models.organization
    50 import soc.models.organization
    53 import soc.logic.models.organization
    51 import soc.logic.models.organization
    54 
    52 
    55 class View(group.View):
    53 class View(group.View):
    61     to provide the user with list, public, create, edit and delete views.
    59     to provide the user with list, public, create, edit and delete views.
    62 
    60 
    63     Params:
    61     Params:
    64       original_params: a dict with params for this View
    62       original_params: a dict with params for this View
    65     """
    63     """
    66 
    64     
       
    65     from soc.views.models import program as program_view
       
    66     
    67     rights = access.Checker(params)
    67     rights = access.Checker(params)
    68     rights['any_access'] = ['allow']
    68     rights['any_access'] = ['allow']
    69     rights['show'] = ['allow']
    69     rights['show'] = ['allow']
    70     rights['create'] = ['checkIsDeveloper']
    70     rights['create'] = ['checkIsDeveloper']
    71     rights['edit'] = [('checkHasActiveRoleForKeyFieldsAsScope',
    71     rights['edit'] = [('checkHasActiveRoleForKeyFieldsAsScope',
   136                 attrs={'rows': 25, 'cols': 100})),
   136                 attrs={'rows': 25, 'cols': 100})),
   137         'contrib_template': forms.fields.CharField(
   137         'contrib_template': forms.fields.CharField(
   138             widget=helper.widgets.FullTinyMCE(
   138             widget=helper.widgets.FullTinyMCE(
   139                 attrs={'rows': 25, 'cols': 100})),
   139                 attrs={'rows': 25, 'cols': 100})),
   140         'clean_description': cleaning.clean_html_content('description'),
   140         'clean_description': cleaning.clean_html_content('description'),
   141         'clean_contrib_template': cleaning.clean_html_content('contrib_template'),
   141         'clean_contrib_template': cleaning.clean_html_content(
       
   142             'contrib_template'),
   142         'clean_ideas': cleaning.clean_url('ideas'),
   143         'clean_ideas': cleaning.clean_url('ideas'),
   143         'clean': cleaning.validate_new_group('link_id', 'scope_path',
   144         'clean': cleaning.validate_new_group('link_id', 'scope_path',
   144             soc.logic.models.organization, org_app_logic)
   145             soc.logic.models.organization, org_app_logic)
   145         }
   146         }
   146 
   147 
   255     # link the proposals to the rank
   256     # link the proposals to the rank
   256     ranking = dict([i for i in itertools.izip(proposals, ranks)])
   257     ranking = dict([i for i in itertools.izip(proposals, ranks)])
   257 
   258 
   258     assigned_proposals = []
   259     assigned_proposals = []
   259 
   260 
   260     # only when the program allows allocations to be seen we should color the list
   261     # only when the program allows allocations 
       
   262     # to be seen we should color the list
   261     if org_entity.scope.allocations_visible:
   263     if org_entity.scope.allocations_visible:
   262       # get the limit and offset for the list
   264       # get the limit and offset for the list
   263       limit, offset = lists.getLimitAndOffset(request, 'offset_0', 'limit_0')
   265       _, offset = lists.getLimitAndOffset(request, 'offset_0', 'limit_0')
   264 
   266 
   265       # determine the amount of proposals to color
   267       # determine the amount of proposals to color
   266       to_color = max(0, org_entity.slots - offset)
   268       to_color = max(0, org_entity.slots - offset)
   267       assigned_proposals = proposals[0:to_color]
   269       assigned_proposals = proposals[0:to_color]
   268 
   270