38 from django.utils.translation import ugettext |
38 from django.utils.translation import ugettext |
39 |
39 |
40 from soc.logic import accounts |
40 from soc.logic import accounts |
41 from soc.logic import dicts |
41 from soc.logic import dicts |
42 from soc.logic import rights as rights_logic |
42 from soc.logic import rights as rights_logic |
|
43 from soc.logic.helper import timeline as timeline_helper |
43 from soc.logic.models.club_admin import logic as club_admin_logic |
44 from soc.logic.models.club_admin import logic as club_admin_logic |
44 from soc.logic.models.club_member import logic as club_member_logic |
45 from soc.logic.models.club_member import logic as club_member_logic |
45 from soc.logic.models.document import logic as document_logic |
46 from soc.logic.models.document import logic as document_logic |
46 from soc.logic.models.host import logic as host_logic |
47 from soc.logic.models.host import logic as host_logic |
47 from soc.logic.models.mentor import logic as mentor_logic |
48 from soc.logic.models.mentor import logic as mentor_logic |
102 'The scope for this request is not active.') |
103 'The scope for this request is not active.') |
103 |
104 |
104 DEF_PAGE_DENIED_MSG = ugettext( |
105 DEF_PAGE_DENIED_MSG = ugettext( |
105 'Access to this page has been restricted') |
106 'Access to this page has been restricted') |
106 |
107 |
|
108 DEF_PAGE_INACTIVE_MSG = ugettext( |
|
109 'This page is inactive at this time') |
|
110 |
107 DEF_LOGOUT_MSG_FMT = ugettext( |
111 DEF_LOGOUT_MSG_FMT = ugettext( |
108 'Please <a href="%(sign_out)s">sign out</a> in order to view this page') |
112 'Please <a href="%(sign_out)s">sign out</a> in order to view this page') |
109 |
113 |
110 DEF_GROUP_NOT_FOUND_MSG = ugettext( |
114 DEF_GROUP_NOT_FOUND_MSG = ugettext( |
111 'The requested Group can not be found') |
115 'The requested Group can not be found') |
675 new_args = {'scope_path': program.scope_path } |
679 new_args = {'scope_path': program.scope_path } |
676 self.checkHasActiveRole(new_args, host_logic) |
680 self.checkHasActiveRole(new_args, host_logic) |
677 |
681 |
678 |
682 |
679 @allowDeveloper |
683 @allowDeveloper |
|
684 @denySidebar |
|
685 def checkIsActivePeriod(self, django_args, period_name, key_name_arg): |
|
686 """Checks if the given period is active for the given program. |
|
687 |
|
688 Args: |
|
689 django_args: a dictionary with django's arguments. |
|
690 period_name: the name of the period which is checked. |
|
691 key_name_arg: the entry in django_args that specifies the given program |
|
692 keyname. If none is given the key_name is constructed from django_args |
|
693 itself. |
|
694 |
|
695 Raises: |
|
696 AccessViolationResponse: |
|
697 * if no active Program is found |
|
698 * if the period is not active |
|
699 """ |
|
700 |
|
701 if key_name_arg and key_name_arg in django_args: |
|
702 key_name = django_args[key_name_arg] |
|
703 else: |
|
704 key_name = program_logic.getKeyNameFromFields(fields) |
|
705 |
|
706 program_entity = program_logic.getFromKeyName(key_name) |
|
707 |
|
708 if not program_entity or ( |
|
709 program_entity.status in ['inactive', 'invalid']): |
|
710 raise out_of_band.AccessViolation(message_fmt=DEF_SCOPE_INACTIVE_MSG) |
|
711 |
|
712 if timeline_helper.isActivePeriod(program_entity.timeline, period_name): |
|
713 return |
|
714 |
|
715 raise out_of_band.AccessViolation(message_fmt=DEF_PAGE_INACTIVE_MSG) |
|
716 |
|
717 def checkCanCreateOrgApp(self, django_args, period_name): |
|
718 if 'seed' in django_args: |
|
719 return self.checkIsActivePeriod(django_args['seed'], |
|
720 period_name, 'scope_path') |
|
721 else: |
|
722 return |
|
723 |
|
724 |
|
725 @allowDeveloper |
680 def checkCanEditGroupApp(self, django_args, group_app_logic): |
726 def checkCanEditGroupApp(self, django_args, group_app_logic): |
681 """Checks if the group_app in args is valid to be edited by the current user. |
727 """Checks if the group_app in args is valid to be edited by the current user. |
682 |
728 |
683 Args: |
729 Args: |
684 group_app_logic: A logic instance for the Group Application |
730 group_app_logic: A logic instance for the Group Application |