author | Madhusudan.C.S <madhusudancs@gmail.com> |
Thu, 22 Oct 2009 09:54:01 +0200 | |
changeset 3027 | a223fff4cca8 |
parent 2951 | c904033c58e1 |
child 3067 | 371e1979ee6a |
permissions | -rw-r--r-- |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
# |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
# |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
# |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
# |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
"""GHOP specific views for Programs. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
import datetime |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
import os |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
from django import forms |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
30 |
from django import http |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
31 |
from django.utils.translation import ugettext |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
32 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
33 |
from soc.logic import cleaning |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
from soc.logic import dicts |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
from soc.logic.helper import timeline as timeline_helper |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
from soc.logic.models import host as host_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
from soc.views import out_of_band |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
from soc.views import helper |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
39 |
from soc.views.helper import decorators |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
from soc.views.helper import dynaform |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
41 |
from soc.views.helper import lists |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
42 |
from soc.views.helper import params as params_helper |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
43 |
from soc.views.helper import redirects |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
44 |
from soc.views.helper import widgets |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
45 |
from soc.views.models import document as document_view |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
46 |
from soc.views.models import program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
47 |
from soc.views.sitemap import sidebar |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
48 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
49 |
import soc.cache.logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
50 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
51 |
from soc.modules.ghop.logic.models import mentor as ghop_mentor_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
52 |
from soc.modules.ghop.logic.models import org_admin as ghop_org_admin_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
53 |
from soc.modules.ghop.logic.models import program as ghop_program_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
54 |
from soc.modules.ghop.logic.models import student as ghop_student_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
55 |
from soc.modules.ghop.logic.models import task as ghop_task_logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
56 |
from soc.modules.ghop.models import task as ghop_task_model |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
57 |
from soc.modules.ghop.views.helper import access as ghop_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
58 |
from soc.modules.ghop.views.helper import redirects as ghop_redirects |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
59 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
60 |
import soc.modules.ghop.logic.models.program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
61 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
62 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
63 |
class View(program.View): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
64 |
"""View methods for the GHOP Program model. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
65 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
66 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
67 |
DEF_PARTICIPATING_ORGS_MSG_FMT = ugettext( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
68 |
'The following is a list of all the participating organizations under ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
69 |
'the programme %(name)s. To know more about each organization and see ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
70 |
'the tasks published by them please visit the corresponding links.') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
71 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
72 |
DEF_TASK_QUOTA_ALLOCATION_MSG = ugettext( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
73 |
"Use this view to assign task quotas.") |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
74 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
75 |
DEF_TASK_QUOTA_ERROR_MSG_FMT = ugettext( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
76 |
"Task Quota limit for the organizations %s do not contain" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
77 |
" a valid number(>0) and has not been updated.") |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
78 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
79 |
def __init__(self, params=None): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
80 |
"""Defines the fields and methods required for the program View class |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
81 |
to provide the user with list, public, create, edit and delete views. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
82 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
83 |
Params: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
84 |
params: a dict with params for this View |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
85 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
86 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
87 |
rights = ghop_access.GHOPChecker(params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
88 |
rights['show'] = ['allow'] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
89 |
rights['create'] = [('checkSeeded', ['checkHasActiveRoleForScope', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
90 |
host_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
91 |
rights['edit'] = [('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
92 |
[ghop_program_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
93 |
rights['delete'] = ['checkIsDeveloper'] |
2951
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
94 |
rights['accepted_orgs'] = [('checkIsAfterEvent', |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
95 |
['student_signup_start', |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
96 |
'__all__', ghop_program_logic.logic])] |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
97 |
rights['task_difficulty'] = [('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
98 |
[ghop_program_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
99 |
rights['task_type'] = [('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
100 |
[ghop_program_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
101 |
rights['difficulty_tag_edit'] = [('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
102 |
[ghop_program_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
103 |
rights['type_tag_edit'] = [('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
104 |
[ghop_program_logic.logic])] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
105 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
106 |
new_params = {} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
107 |
new_params['logic'] = soc.modules.ghop.logic.models.program.logic |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
108 |
new_params['rights'] = rights |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
109 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
110 |
new_params['name'] = "GHOP Program" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
111 |
new_params['module_name'] = "program" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
112 |
new_params['sidebar_grouping'] = 'Programs' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
113 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
114 |
new_params['module_package'] = 'soc.modules.ghop.views.models' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
115 |
new_params['url_name'] = 'ghop/program' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
116 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
117 |
# TODO: this list can be reduced after GSoC has been moved |
2935
0b8b82b6764e
Removed slots and apps_tasks_limit from extra_dynaexclude in params and added a getExtraMenus entry to callback for program.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2891
diff
changeset
|
118 |
new_params['extra_dynaexclude'] = ['min_slots', 'max_slots', |
0b8b82b6764e
Removed slots and apps_tasks_limit from extra_dynaexclude in params and added a getExtraMenus entry to callback for program.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2891
diff
changeset
|
119 |
'slot_allocation', 'allocations_visible', |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
120 |
'task_difficulties', 'task_types', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
121 |
] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
122 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
123 |
patterns = [] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
124 |
patterns += [ |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
125 |
(r'^%(url_name)s/(?P<access_type>assign_task_quotas)/%(key_fields)s$', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
126 |
'%(module_package)s.%(module_name)s.assign_task_quotas', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
127 |
'Assign task quota limits'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
128 |
(r'^%(url_name)s/(?P<access_type>task_difficulty)/%(key_fields)s$', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
129 |
'%(module_package)s.%(module_name)s.task_difficulty_edit', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
130 |
'Edit Task Difficulty Tags'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
131 |
(r'^%(url_name)s/(?P<access_type>task_type)/%(key_fields)s$', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
132 |
'%(module_package)s.%(module_name)s.task_type_edit', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
133 |
'Edit Task Type Tags'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
134 |
(r'^%(url_name)s/(?P<access_type>difficulty_tag_edit)$', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
135 |
'%(module_package)s.%(module_name)s.difficulty_tag_edit', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
136 |
'Edit a Difficulty Tag'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
137 |
(r'^%(url_name)s/(?P<access_type>type_tag_edit)$', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
138 |
'%(module_package)s.%(module_name)s.task_type_tag_edit', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
139 |
'Edit a Task Type Tag'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
140 |
] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
141 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
142 |
new_params['extra_django_patterns'] = patterns |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
143 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
144 |
params = dicts.merge(params, new_params, sub_merge=True) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
145 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
146 |
super(View, self).__init__(params=params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
147 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
148 |
dynafields = [ |
2940
ef809d10aaf1
Fixed error occuring when tags list was empty in GHOPProgram edit View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2935
diff
changeset
|
149 |
{'name': 'overview_task_difficulties', |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
150 |
'base': forms.CharField, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
151 |
'label': 'Task Difficulty Levels', |
2940
ef809d10aaf1
Fixed error occuring when tags list was empty in GHOPProgram edit View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2935
diff
changeset
|
152 |
'group': 'Task Settings', |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
153 |
'widget': widgets.ReadOnlyInput(), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
154 |
'required': False, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
155 |
'help_text': ugettext('Lists all the difficulty levels that ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
156 |
'can be assigned to a task. Edit them ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
157 |
'from the Program menu on sidebar.'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
158 |
}, |
2940
ef809d10aaf1
Fixed error occuring when tags list was empty in GHOPProgram edit View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2935
diff
changeset
|
159 |
{'name': 'overview_task_types', |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
160 |
'base': forms.CharField, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
161 |
'label': 'Task Type Tags', |
2940
ef809d10aaf1
Fixed error occuring when tags list was empty in GHOPProgram edit View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2935
diff
changeset
|
162 |
'group': 'Task Settings', |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
163 |
'widget': widgets.ReadOnlyInput(), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
164 |
'required': False, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
165 |
'help_text': ugettext('Lists all the types a task can be in. ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
166 |
'Edit them from the Program menu on sidebar.'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
167 |
}, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
168 |
] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
169 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
170 |
dynaproperties = params_helper.getDynaFields(dynafields) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
171 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
172 |
edit_form = dynaform.extendDynaForm( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
173 |
dynaform=self._params['edit_form'], |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
174 |
dynaproperties=dynaproperties) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
175 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
176 |
self._params['edit_form'] = edit_form |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
177 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
178 |
def _editGet(self, request, entity, form): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
179 |
"""See base.View._editGet(). |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
180 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
181 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
182 |
# TODO: can't a simple join operation do this? |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
183 |
tds = ghop_task_model.TaskDifficultyTag.get_by_scope(entity) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
184 |
if tds: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
185 |
td_str = '' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
186 |
for td in tds[:-1]: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
187 |
td_str += str(td) + ', ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
188 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
189 |
td_str += str(tds[-1]) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
190 |
|
2941
5d2afe70420d
Bron paper bag fix, should have been part of ref809d10aa.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2940
diff
changeset
|
191 |
form.fields['overview_task_difficulties'].initial = td_str |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
192 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
193 |
tts = ghop_task_model.TaskTypeTag.get_by_scope(entity) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
194 |
if tts: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
195 |
tt_str = '' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
196 |
for tt in tts[:-1]: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
197 |
tt_str += str(tt) + ', ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
198 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
199 |
tt_str += str(tts[-1]) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
200 |
|
2941
5d2afe70420d
Bron paper bag fix, should have been part of ref809d10aa.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2940
diff
changeset
|
201 |
form.fields['overview_task_types'].initial = tt_str |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
202 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
203 |
return super(View, self)._editGet(request, entity, form) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
204 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
205 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
206 |
@decorators.check_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
207 |
def assignTaskQuotas(self, request, access_type, page_name=None, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
208 |
params=None, filter=None, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
209 |
"""View that allows to assign task quotas for accepted GHOP organization. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
210 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
211 |
This view allows the program admin to set the task quota limits |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
212 |
and change them at any time when the program is active. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
213 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
214 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
215 |
# TODO: Once GAE Task APIs arrive, this view will be managed by them |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
216 |
program = ghop_program_logic.logic.getFromKeyFieldsOr404(kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
217 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
218 |
from soc.modules.ghop.views.models import \ |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
219 |
organization as ghop_organization_view |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
220 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
221 |
org_params = ghop_organization_view.view.getParams().copy() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
222 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
223 |
context = {} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
224 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
225 |
if request.method == 'POST': |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
226 |
return self.assignTaskQuotasPost(request, context, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
227 |
page_name, params, program, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
228 |
**kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
229 |
else: # request.method == 'GET' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
230 |
return self.assignTaskQuotasGet(request, context, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
231 |
page_name, params, program, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
232 |
**kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
233 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
234 |
def assignTaskQuotasPost(self, request, context, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
235 |
page_name, params, entity, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
236 |
"""Handles the POST request for the task quota allocation page. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
237 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
238 |
Args: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
239 |
entity: the program entity |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
240 |
rest: see base.View.public() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
241 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
242 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
243 |
ghop_org_logic = org_params['logic'] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
244 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
245 |
error_orgs = '' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
246 |
for link_id, task_count in request.POST.items(): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
247 |
fields = { |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
248 |
'link_id': link_id, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
249 |
'scope': entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
250 |
'scope_path': entity.key().id_or_name(), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
251 |
} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
252 |
key_name = ghop_org_logic.getKeyNameFromFields(fields) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
253 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
254 |
try: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
255 |
task_count = int(task_count) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
256 |
if task_count >= 0: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
257 |
fields['task_quota_limit'] = task_count |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
258 |
ghop_org_logic.updateOrCreateFromKeyName(fields, key_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
259 |
else: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
260 |
raise ValueError |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
261 |
except ValueError: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
262 |
org_entity = ghop_org_logic.getFromKeyName(key_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
263 |
error_orgs += org_entity.name + ', ' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
264 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
265 |
if error_orgs: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
266 |
context['error_message'] = self.DEF_TASK_QUOTA_ERROR_MSG_FMT % ( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
267 |
error_orgs[:-2]) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
268 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
269 |
return self.assignTaskQuotasGet(request, context, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
270 |
page_name, params, entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
271 |
**kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
272 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
273 |
# redirect to the same page |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
274 |
return http.HttpResponseRedirect('') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
275 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
276 |
def assignTaskQuotasGet(self, request, context, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
277 |
page_name, params, entity, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
278 |
"""Handles the GET request for the task quota allocation page. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
279 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
280 |
Args: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
281 |
entity: the program entity |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
282 |
rest see base.View.public() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
283 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
284 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
285 |
org_params['list_template'] = ('modules/ghop/program/' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
286 |
'allocation/allocation.html') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
287 |
org_params['list_heading'] = ('modules/ghop/program/' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
288 |
'allocation/heading.html') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
289 |
org_params['list_row'] = 'modules/ghop/program/allocation/row.html' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
290 |
org_params['list_pagination'] = 'soc/list/no_pagination.html' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
291 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
292 |
description = self.DEF_TASK_QUOTA_ALLOCATION_MSG |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
293 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
294 |
filter = { |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
295 |
'scope': entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
296 |
'status': 'active', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
297 |
} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
298 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
299 |
content = self._getAcceptedOrgsList(description, org_params, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
300 |
filter, False) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
301 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
302 |
contents = [content] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
303 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
304 |
return self._list(request, org_params, contents, page_name, context) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
305 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
306 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
307 |
def getExtraMenus(self, id, user, params=None): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
308 |
"""See soc.views.models.program.View.getExtraMenus(). |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
309 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
310 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
311 |
logic = params['logic'] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
312 |
rights = params['rights'] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
313 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
314 |
# only get all invisible and visible programs |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
315 |
fields = {'status': ['invisible', 'visible']} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
316 |
entities = logic.getForFields(fields) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
317 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
318 |
menus = [] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
319 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
320 |
rights.setCurrentUser(id, user) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
321 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
322 |
for entity in entities: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
323 |
items = [] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
324 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
325 |
if entity.status == 'visible': |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
326 |
# show the documents for this program, even for not logged in users |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
327 |
items += document_view.view.getMenusForScope(entity, params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
328 |
items += self._getTimeDependentEntries(entity, params, id, user) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
329 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
330 |
try: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
331 |
# check if the current user is a host for this program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
332 |
rights.doCachedCheck('checkIsHostForProgram', |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
333 |
{'scope_path': entity.scope_path, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
334 |
'link_id': entity.link_id}, []) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
335 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
336 |
if entity.status == 'invisible': |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
337 |
# still add the document links so hosts can see how it looks like |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
338 |
items += document_view.view.getMenusForScope(entity, params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
339 |
items += self._getTimeDependentEntries(entity, params, id, user) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
340 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
341 |
items += [(redirects.getReviewOverviewRedirect( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
342 |
entity, {'url_name': 'ghop/org_app', 'scope_view': self}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
343 |
"Review Organization Applications", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
344 |
# add link to edit Program Profile |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
345 |
items += [(redirects.getEditRedirect(entity, params), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
346 |
'Edit Program Profile', 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
347 |
# add link to Assign Task Quota limits |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
348 |
items += [(ghop_redirects.getAssignTaskQuotasRedirect(entity, params), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
349 |
'Assign Task Quota limits', 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
350 |
# add link to edit Program Timeline |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
351 |
items += [(redirects.getEditRedirect( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
352 |
entity, {'url_name': 'ghop/timeline'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
353 |
"Edit Program Timeline", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
354 |
# add link to create a new Program Document |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
355 |
items += [(redirects.getCreateDocumentRedirect(entity, 'ghop/program'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
356 |
"Create a New Document", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
357 |
# add link to list all Program Document |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
358 |
items += [(redirects.getListDocumentsRedirect(entity, 'ghop/program'), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
359 |
"List Documents", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
360 |
# add link to edit Task Difficulty Levels |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
361 |
items += [(ghop_redirects.getDifficultyEditRedirect( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
362 |
entity, {'url_name': 'ghop/program'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
363 |
"Edit Task Difficulty Levels", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
364 |
# add link to edit Task Type Tags |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
365 |
items += [(ghop_redirects.getTaskTypeEditRedirect( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
366 |
entity, {'url_name': 'ghop/program'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
367 |
"Edit Task Type Tags", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
368 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
369 |
except out_of_band.Error: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
370 |
pass |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
371 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
372 |
items = sidebar.getSidebarMenu(id, user, items, params=params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
373 |
if not items: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
374 |
continue |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
375 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
376 |
menu = {} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
377 |
menu['heading'] = entity.short_name |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
378 |
menu['items'] = items |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
379 |
menu['group'] = 'Programs' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
380 |
menus.append(menu) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
381 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
382 |
return menus |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
383 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
384 |
def _getTimeDependentEntries(self, ghop_program_entity, params, id, user): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
385 |
"""Returns a list with time dependent menu items. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
386 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
387 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
388 |
items = [] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
389 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
390 |
timeline_entity = ghop_program_entity.timeline |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
391 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
392 |
# get the student entity for this user and program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
393 |
filter = {'user': user, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
394 |
'scope': ghop_program_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
395 |
'status': 'active'} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
396 |
student_entity = ghop_student_logic.logic.getForFields(filter, unique=True) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
397 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
398 |
if student_entity: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
399 |
items += self._getStudentEntries(ghop_program_entity, student_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
400 |
params, id, user) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
401 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
402 |
# get mentor and org_admin entity for this user and program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
403 |
filter = {'user': user, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
404 |
'program': ghop_program_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
405 |
'status': 'active'} |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
406 |
mentor_entity = ghop_mentor_logic.logic.getForFields(filter, unique=True) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
407 |
org_admin_entity = ghop_org_admin_logic.logic.getForFields( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
408 |
filter, unique=True) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
409 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
410 |
if mentor_entity or org_admin_entity: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
411 |
items += self._getOrganizationEntries( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
412 |
ghop_program_entity, org_admin_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
413 |
mentor_entity, params, id, user) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
414 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
415 |
if user and not (student_entity or mentor_entity or org_admin_entity): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
416 |
if timeline_helper.isActivePeriod(timeline_entity, 'student_signup'): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
417 |
# this user does not have a role yet for this program |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
418 |
items += [('/ghop/student/apply/%s' % ( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
419 |
ghop_program_entity.key().id_or_name()), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
420 |
"Register as a Student", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
421 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
422 |
if timeline_helper.isAfterEvent(timeline_entity, 'org_signup_start'): |
2951
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
423 |
url = redirects.getAcceptedOrgsRedirect( |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
424 |
ghop_program_entity, params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
425 |
# add a link to list all the organizations |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
426 |
items += [(url, "List participating Organizations", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
427 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
428 |
return items |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
429 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
430 |
def _getStudentEntries(self, ghop_program_entity, student_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
431 |
params, id, user): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
432 |
"""Returns a list with menu items for students in a specific program. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
433 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
434 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
435 |
items = [] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
436 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
437 |
timeline_entity = ghop_program_entity.timeline |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
438 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
439 |
if timeline_helper.isAfterEvent(timeline_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
440 |
'student_signup_start'): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
441 |
# add a link to show all projects |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
442 |
items += [(redirects.getListProjectsRedirect(ghop_program_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
443 |
{'url_name':'ghop/task'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
444 |
"List my Tasks", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
445 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
446 |
items += [(redirects.getEditRedirect(student_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
447 |
{'url_name': 'ghop/student'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
448 |
"Edit my Student Profile", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
449 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
450 |
items += [(redirects.getManageRedirect(student_entity, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
451 |
{'url_name':'ghop/student'}), |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
452 |
"Resign as a Student", 'any_access')] |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
453 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
454 |
return items |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
455 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
456 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
457 |
@decorators.check_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
458 |
def taskDifficultyEdit(self, request, access_type, page_name=None, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
459 |
params=None, filter=None, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
460 |
"""View method used to edit Difficulty Level tags. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
461 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
462 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
463 |
params = dicts.merge(params, self._params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
464 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
465 |
try: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
466 |
entity = self._logic.getFromKeyFieldsOr404(kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
467 |
except out_of_band.Error, error: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
468 |
return helper.responses.errorResponse( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
469 |
error, request, template=params['error_public']) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
470 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
471 |
context = helper.responses.getUniversalContext(request) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
472 |
helper.responses.useJavaScript(context, params['js_uses_all']) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
473 |
context['page_name'] = page_name |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
474 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
475 |
context['program_key_name'] = entity.key().name() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
476 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
477 |
context['difficulties'] = ghop_task_model.TaskDifficultyTag.get_by_scope( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
478 |
entity) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
479 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
480 |
params['edit_template'] = 'modules/ghop/program/tag/difficulty.html' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
481 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
482 |
return self._constructResponse(request, entity, context, None, params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
483 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
484 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
485 |
@decorators.check_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
486 |
def difficultyTagEdit(self, request, access_type, page_name=None, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
487 |
params=None, filter=None, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
488 |
"""View method used to edit a supplied Difficulty level tag. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
489 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
490 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
491 |
get_params = request.GET |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
492 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
493 |
order = get_params.getlist('order') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
494 |
program_key_name = get_params.get('program_key_name') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
495 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
496 |
program_entity = ghop_program_logic.logic.getFromKeyName( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
497 |
program_key_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
498 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
499 |
if order: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
500 |
for index, elem in enumerate(order): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
501 |
ghop_task_model.TaskDifficultyTag.update_order( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
502 |
program_entity, elem, index) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
503 |
return http.HttpResponse() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
504 |
else: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
505 |
tag_data = get_params.getlist('tag_data') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
506 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
507 |
tag_name = tag_data[0].strip() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
508 |
tag_value = tag_data[1].strip() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
509 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
510 |
if tag_name: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
511 |
if not tag_value: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
512 |
ghop_task_model.TaskDifficultyTag.delete_tag( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
513 |
program_entity, tag_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
514 |
elif tag_name != tag_value: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
515 |
ghop_task_model.TaskDifficultyTag.copy_tag( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
516 |
program_entity, tag_name, tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
517 |
else: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
518 |
ghop_task_model.TaskDifficultyTag.get_or_create( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
519 |
program_entity, tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
520 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
521 |
return http.HttpResponse(tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
522 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
523 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
524 |
@decorators.check_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
525 |
def taskTypeEdit(self, request, access_type, page_name=None, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
526 |
params=None, filter=None, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
527 |
"""View method used to edit Task Type tags. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
528 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
529 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
530 |
params = dicts.merge(params, self._params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
531 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
532 |
try: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
533 |
entity = self._logic.getFromKeyFieldsOr404(kwargs) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
534 |
except out_of_band.Error, error: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
535 |
return helper.responses.errorResponse( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
536 |
error, request, template=params['error_public']) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
537 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
538 |
context = helper.responses.getUniversalContext(request) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
539 |
helper.responses.useJavaScript(context, params['js_uses_all']) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
540 |
context['page_name'] = page_name |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
541 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
542 |
context['program_key_name'] = entity.key().name() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
543 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
544 |
context['task_types'] = ghop_task_model.TaskTypeTag.get_by_scope( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
545 |
entity) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
546 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
547 |
params['edit_template'] = 'modules/ghop/program/tag/task_type.html' |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
548 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
549 |
return self._constructResponse(request, entity, context, None, params) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
550 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
551 |
@decorators.merge_params |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
552 |
@decorators.check_access |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
553 |
def taskTypeTagEdit(self, request, access_type, page_name=None, |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
554 |
params=None, filter=None, **kwargs): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
555 |
"""View method used to edit a supplied Task Type tag. |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
556 |
""" |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
557 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
558 |
get_params = request.GET |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
559 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
560 |
order = get_params.getlist('order') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
561 |
program_key_name = get_params.get('program_key_name') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
562 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
563 |
program_entity = ghop_program_logic.logic.getFromKeyName( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
564 |
program_key_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
565 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
566 |
if order: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
567 |
for index, elem in enumerate(order): |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
568 |
ghop_task_model.TaskTypeTag.update_order( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
569 |
program_entity, elem, index) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
570 |
return http.HttpResponse() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
571 |
else: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
572 |
tag_data = get_params.getlist('tag_data') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
573 |
program_key_name = get_params.get('program_key_name') |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
574 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
575 |
tag_name = tag_data[0].strip() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
576 |
tag_value = tag_data[1].strip() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
577 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
578 |
program_entity = ghop_program_logic.logic.getFromKeyName( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
579 |
program_key_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
580 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
581 |
if tag_name: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
582 |
if not tag_value: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
583 |
ghop_task_model.TaskTypeTag.delete_tag( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
584 |
program_entity, tag_name) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
585 |
elif tag_name != tag_value: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
586 |
ghop_task_model.TaskTypeTag.copy_tag( |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
587 |
program_entity, tag_name, tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
588 |
else: |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
589 |
ghop_task_model.TaskTypeTag.get_or_create(program_entity, tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
590 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
591 |
return http.HttpResponse(tag_value) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
592 |
|
2951
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
593 |
@decorators.merge_params |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
594 |
@decorators.check_access |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
595 |
def acceptedOrgs(self, request, access_type, |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
596 |
page_name=None, params=None, filter=None, **kwargs): |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
597 |
"""List all the accepted orgs for the given program. |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
598 |
""" |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
599 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
600 |
from soc.modules.ghop.views.models.organization import view as \ |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
601 |
ghop_org_view |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
602 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
603 |
contents = [] |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
604 |
logic = params['logic'] |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
605 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
606 |
ghop_program_entity = logic.getFromKeyFieldsOr404(kwargs) |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
607 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
608 |
ao_params = ghop_org_view.getParams().copy() |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
609 |
ao_params['list_action'] = (redirects.getHomeRedirect, |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
610 |
ao_params) |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
611 |
ao_params['list_description'] = self.DEF_PARTICIPATING_ORGS_MSG_FMT % { |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
612 |
'name': ghop_program_entity.name |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
613 |
} |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
614 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
615 |
filter = { |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
616 |
'scope': ghop_program_entity, |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
617 |
'status': ['new', 'active'], |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
618 |
} |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
619 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
620 |
order = ['name'] |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
621 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
622 |
ao_list = lists.getListContent(request, ao_params, filter=filter, |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
623 |
order=order, idx=0) |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
624 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
625 |
contents.append(ao_list) |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
626 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
627 |
params = params.copy() |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
628 |
params['list_msg'] = ghop_program_entity.accepted_orgs_msg |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
629 |
|
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
630 |
return self._list(request, params, contents, page_name) |
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
631 |
|
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
632 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
633 |
view = View() |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
634 |
|
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
635 |
admin = decorators.view(view.admin) |
2951
c904033c58e1
Added listing of all Accepted GHOPOrganizations to the Program View.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2941
diff
changeset
|
636 |
accepted_orgs = decorators.view(view.acceptedOrgs) |
2891
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
637 |
assign_task_quotas = decorators.view(view.assignTaskQuotas) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
638 |
create = decorators.view(view.create) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
639 |
delete = decorators.view(view.delete) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
640 |
edit = decorators.view(view.edit) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
641 |
list = decorators.view(view.list) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
642 |
public = decorators.view(view.public) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
643 |
export = decorators.view(view.export) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
644 |
home = decorators.view(view.home) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
645 |
difficulty_tag_edit = decorators.view(view.difficultyTagEdit) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
646 |
task_type_tag_edit = decorators.view(view.taskTypeTagEdit) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
647 |
task_difficulty_edit = decorators.view(view.taskDifficultyEdit) |
aba681d72b0a
Added GHOP Program View.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
648 |
task_type_edit = decorators.view(view.taskTypeEdit) |