author | Sverre Rabbelier <srabbelier@gmail.com> |
Sat, 12 Sep 2009 00:36:49 +0200 | |
changeset 2898 | ac5f77cd6046 |
parent 2858 | 9b59d89e6707 |
child 3082 | da8cc38cabe9 |
permissions | -rw-r--r-- |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
# |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
# Copyright 2009 the Melange authors. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
# |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
8 |
# |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
10 |
# |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
16 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
17 |
"""This module contains the GHOP Task Model. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
18 |
""" |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
19 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
20 |
__authors__ = [ |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
21 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
22 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
23 |
] |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
24 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
25 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
26 |
from google.appengine.ext import db |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
27 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
28 |
from django.utils.translation import ugettext |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
29 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
30 |
from taggable.taggable import Tag |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
31 |
from taggable.taggable import Taggable |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
32 |
from taggable.taggable import tag_property |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
33 |
|
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
34 |
import soc.models.linkable |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
35 |
import soc.models.role |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
36 |
import soc.models.student |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
37 |
import soc.models.user |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
38 |
|
2407
e23fce20ad3a
Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
2399
diff
changeset
|
39 |
import soc.modules.ghop.models.program |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
40 |
|
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
41 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
42 |
class TaskTag(Tag): |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
43 |
"""Model for storing all Task tags. |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
44 |
""" |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
45 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
46 |
#: Each task_type tag is scoped under the program. |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
47 |
scope = db.ReferenceProperty(reference_class=soc.models.linkable.Linkable, |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
48 |
required=True, |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
49 |
collection_name='task_type_tags') |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
50 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
51 |
order = db.IntegerProperty(required=True, default=0) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
52 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
53 |
@classmethod |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
54 |
def __key_name(cls, scope_path, tag_name): |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
55 |
"""Create the key_name from program key_name as scope_path and tag_name. |
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
56 |
""" |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
57 |
return scope_path + '/' + tag_name |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
58 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
59 |
@classmethod |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
60 |
def get_by_name(cls, tag_name): |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
61 |
"""Get the list of tag objects that has the given tag_name. |
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
62 |
""" |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
63 |
tags = db.Query(cls).filter('tag =', tag_name).fetch(1000) |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
64 |
return tags |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
65 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
66 |
@classmethod |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
67 |
def get_by_scope(cls, scope): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
68 |
"""Get the list of tag objects that has the given scope. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
69 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
70 |
tags = db.Query(cls).filter('scope =', scope).order('order').fetch(1000) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
71 |
return tags |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
72 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
73 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
74 |
def get_highest_order(cls, scope): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
75 |
"""Get a tag with highest order. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
76 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
77 |
tags = db.Query(cls).filter('scope =', scope).order('-order').fetch(1) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
78 |
if tags: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
79 |
return tags[0].order |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
80 |
else: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
81 |
return -1 |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
82 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
83 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
84 |
def get_by_scope_and_name(cls, scope, tag_name): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
85 |
"""Get a tag by scope and name. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
86 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
87 |
There can be only one such tag. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
88 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
89 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
90 |
tags = db.Query(cls).filter( |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
91 |
'scope =', scope).filter('tag =', tag_name).fetch(1) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
92 |
if tags: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
93 |
return tags[0] |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
94 |
else: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
95 |
return None |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
96 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
97 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
98 |
def update_order(cls, scope, tag_name, order): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
99 |
"""Updates the order of the tag. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
100 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
101 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
102 |
tag = cls.get_by_scope_and_name(scope, tag_name) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
103 |
if tag: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
104 |
tag.order = order |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
105 |
tag.put() |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
106 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
107 |
return tag |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
108 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
109 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
110 |
def copy_tag(cls, scope, tag_name, new_tag_name): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
111 |
"""Copy a tag with a given scope and tag_name to another tag with |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
112 |
new tag_name. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
113 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
114 |
tag = cls.get_by_scope_and_name(scope, tag_name) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
115 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
116 |
if tag: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
117 |
tag_key_name = cls.__key_name(scope.key().name(), new_tag_name) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
118 |
existing_tag = cls.get_by_key_name(tag_key_name) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
119 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
120 |
if existing_tag is None: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
121 |
new_tag = cls(key_name=tag_key_name, tag=new_tag_name, scope=scope, |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
122 |
added=tag.added, tagged=tag.tagged, |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
123 |
tagged_count=tag.tagged_count) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
124 |
new_tag.put() |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
125 |
tag.delete() |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
126 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
127 |
return new_tag |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
128 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
129 |
return existing_tag |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
130 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
131 |
return None |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
132 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
133 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
134 |
def delete_tag(cls, scope, tag_name): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
135 |
"""Copy a tag with a given scope and tag_name to another tag with |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
136 |
new tag_name. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
137 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
138 |
tag = cls.get_by_scope_and_name(scope, tag_name) |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
139 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
140 |
if tag: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
141 |
tag.delete() |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
142 |
return True |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
143 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
144 |
return False |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
145 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
146 |
@classmethod |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
147 |
def get_or_create(cls, scope, tag_name, order=0): |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
148 |
"""Get the Tag object that has the tag value given by tag_value. |
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
149 |
""" |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
150 |
tag_key_name = cls.__key_name(scope.key().name(), tag_name) |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
151 |
existing_tag = cls.get_by_key_name(tag_key_name) |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
152 |
if existing_tag is None: |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
153 |
# the tag does not yet exist, so create it. |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
154 |
if not order: |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
155 |
order = cls.get_highest_order(scope=scope) + 1 |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
156 |
def create_tag_txn(): |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
157 |
new_tag = cls(key_name=tag_key_name, tag=tag_name, |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
158 |
scope=scope, order=order) |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
159 |
new_tag.put() |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
160 |
return new_tag |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
161 |
existing_tag = db.run_in_transaction(create_tag_txn) |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
162 |
return existing_tag |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
163 |
|
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
164 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
165 |
class TaskTypeTag(TaskTag): |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
166 |
"""Model for storing of task type tags. |
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
167 |
""" |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
168 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
169 |
pass |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
170 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
171 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
172 |
class TaskDifficultyTag(TaskTag): |
2703
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
173 |
"""Model for storing of task difficulty level tags. |
7117c43ccf1b
Style fixes in the ghop task model module.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2679
diff
changeset
|
174 |
""" |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
175 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
176 |
pass |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
177 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
178 |
|
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
179 |
class TaskArbitraryTag(TaskTag): |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
180 |
"""Model for storing of arbitrary tags. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
181 |
""" |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
182 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
183 |
pass |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
184 |
|
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
185 |
|
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
186 |
class GHOPTask(Taggable, soc.models.linkable.Linkable): |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
187 |
"""Model for a task used in GHOP workflow. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
188 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
189 |
The scope property of Linkable will be set to the Organization to which |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
190 |
this task belongs to. A link_id will be generated automatically and will |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
191 |
have no specific meaning other than identification. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
192 |
""" |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
193 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
194 |
#: Required field indicating the "title" of the task |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
195 |
title = db.StringProperty(required=True, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
196 |
verbose_name=ugettext('Title')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
197 |
title.help_text = ugettext('Title of the task') |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
198 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
199 |
#: Required field containing the description of the task |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
200 |
description = db.TextProperty(required=True, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
201 |
verbose_name=ugettext('Description')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
202 |
description.help_text = ugettext('Complete description of the task') |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
203 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
204 |
#: Field indicating the difficulty level of the Task. This is not |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
205 |
#: mandatory so the it can be assigned at any later stage. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
206 |
#: The options are configured by a Program Admin. |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
207 |
difficulty = tag_property('difficulty') |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
208 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
209 |
#: Required field which contains the type of the task. These types are |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
210 |
#: configured by a Program Admin. |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
211 |
task_type = tag_property('task_type') |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
212 |
|
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
213 |
#: Field which contains the arbitrary tags for the task. These tags can |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
214 |
#: be assigned by Org Admins and mentors. |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
215 |
arbit_tag = tag_property('arbit_tag') |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
216 |
|
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
217 |
#: A field which contains time allowed for completing the task (in hours) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
218 |
#: from the moment that this task has been assigned to a Student |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
219 |
time_to_complete = db.IntegerProperty(required=True, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
220 |
verbose_name=('Time to Complete')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
221 |
time_to_complete.help_text = ugettext( |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
222 |
'Time allowed to complete the task, in hours, once it is claimed') |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
223 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
224 |
#: List of Mentors assigned to this task. A Mentor who creates this |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
225 |
#: task is assigned as the Mentor by default. An Org Admin will have |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
226 |
#: to assign a Mentor upon task creation. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
227 |
mentors = db.ListProperty(item_type=db.Key, default=[]) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
228 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
229 |
#: User profile to whom this task has been claimed by. This field |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
230 |
#: is mandatory for claimed tasks |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
231 |
user = db.ReferenceProperty(reference_class=soc.models.user.User, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
232 |
required=False, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
233 |
collection_name='assigned_tasks') |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
234 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
235 |
#: Student profile to whom this task is currently assigned to. If the user |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
236 |
#: has registered as a Student than this field will be filled in. This field |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
237 |
#: is mandatory for all Tasks in the closed state. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
238 |
student = db.ReferenceProperty(reference_class=soc.models.student.Student, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
239 |
required=False, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
240 |
collection_name='assigned_tasks') |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
241 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
242 |
#: Program in which this Task has been created |
2399
65a83ae32703
Changed imports in models to comply with recent GHOP code move.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2397
diff
changeset
|
243 |
program = db.ReferenceProperty( |
2407
e23fce20ad3a
Changed GHOP module imports to be consistent with rest of Melange code.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
2399
diff
changeset
|
244 |
reference_class=soc.modules.ghop.models.program.GHOPProgram, |
2399
65a83ae32703
Changed imports in models to comply with recent GHOP code move.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
2397
diff
changeset
|
245 |
required=True, collection_name='tasks') |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
246 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
247 |
#: Required property which holds the state, the Task is currently in. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
248 |
#: This is a hidden field not shown on forms. Handled by logic internally. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
249 |
#: The state can be one of the following: |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
250 |
#: Unapproved: If Task is created by a Mentor, this is the automatically |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
251 |
#: assigned state. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
252 |
#: Unpublished: This Task is not published yet. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
253 |
#: Open: This Task is open and ready to be claimed. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
254 |
#: Reopened: This Task has been claimed but never finished and has been |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
255 |
#: reopened. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
256 |
#: ClaimRequested: A Student has requested to claim this task. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
257 |
#: Claimed: This Task has been claimed and someone is working on it. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
258 |
#: ActionNeeded: Work on this Task must be submitted for review within |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
259 |
#: 24 hours. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
260 |
#: Closed: Work on this Task has been completed to the org's content. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
261 |
#: AwaitingRegistration: Student has completed work on this task, but |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
262 |
#: needs to complete Student registration before this task is closed. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
263 |
#: NeedsWork: This work on this Tasks needs a bit more brushing up. This |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
264 |
#: state is followed by a Mentor review. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
265 |
#: NeedsReview: Student has submitted work for this task and it should |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
266 |
#: be reviewed by a Mentor. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
267 |
#: Invalid: The Task is deleted either by an Org Admin/Mentor |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
268 |
status = db.StringProperty( |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
269 |
required=True, verbose_name=ugettext('Status'), |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
270 |
choices=['Unapproved', 'Unpublished', 'Open', 'Reopened', |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
271 |
'ClaimRequested', 'Claimed', 'ActionNeeded', |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
272 |
'Closed', 'AwaitingRegistration', 'NeedsWork', |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
273 |
'NeedsReview', 'Invalid'], |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
274 |
default='Unapproved') |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
275 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
276 |
#: This field is set to the next deadline that will have consequences for |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
277 |
#: this Task. For instance this will store a DateTime property which will |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
278 |
#: tell when this Task should be completed. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
279 |
deadline = db.DateTimeProperty(required=False, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
280 |
verbose_name=ugettext('Deadline')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
281 |
|
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
282 |
#: Required field containing the Mentor/Org Admin who created this task. |
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
283 |
#: If site developer has created the task, it is empty. |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
284 |
created_by = db.ReferenceProperty(reference_class=soc.models.role.Role, |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
285 |
required=False, |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
286 |
collection_name='created_tasks', |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
287 |
verbose_name=ugettext('Created by')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
288 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
289 |
#: Date when the proposal was created |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
290 |
created_on = db.DateTimeProperty(required=True, auto_now_add=True, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
291 |
verbose_name=ugettext('Created on')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
292 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
293 |
#: Required field containing the Mentor/Org Admin who last edited this |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
294 |
#: task. It changes only when Mentor/Org Admin changes title, description, |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
295 |
#: difficulty, task_type, time_to_complete. If site developer has modified |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
296 |
#: the task, it is empty. |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
297 |
modified_by = db.ReferenceProperty(reference_class=soc.models.role.Role, |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
298 |
required=False, |
2397
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
299 |
collection_name='edited_tasks', |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
300 |
verbose_name=ugettext('Modified by')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
301 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
302 |
#: Date when the proposal was last modified, should be set manually on edit |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
303 |
modified_on = db.DateTimeProperty(required=True, auto_now_add=True, |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
304 |
verbose_name=ugettext('Modified on')) |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
305 |
|
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
306 |
#: A field which holds the entire history of this task in JSON. The |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
307 |
#: structure of this JSON string is as follows: |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
308 |
#: { |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
309 |
#: timestamp1: { |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
310 |
#: "user": User reference |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
311 |
#: "student": Student reference |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
312 |
#: ... |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
313 |
#: "state": "Unapproved" |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
314 |
#: ... |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
315 |
#: "edited_by": Role reference |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
316 |
#: |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
317 |
#: } |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
318 |
#: timestamp2: { |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
319 |
#: "state": "Unpublished" |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
320 |
#: } |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
321 |
#: } |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
322 |
#: First dictionary item holds the values for all the properties in this |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
323 |
#: model. The subsequent items hold the properties that changed at the |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
324 |
#: timestamp given by the key. |
d943fa182fae
Moved the GHOP module into the modules package.
Madhusudan C.S. <madhusudancs@gmail.com>
parents:
diff
changeset
|
325 |
#: Reference properties will be stored by calling str() on their Key. |
2788
78d02dcd8eb0
Changed all status to start with Uppercase letters, made 3 properties required.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2703
diff
changeset
|
326 |
history = db.TextProperty(required=False, default='') |
2679
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
327 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
328 |
def __init__(self, parent=None, key_name=None, |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
329 |
app=None, **entity_values): |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
330 |
"""Constructor for GHOPTask Model. |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
331 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
332 |
Args: |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
333 |
See Google App Engine APIs. |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
334 |
""" |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
335 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
336 |
# explicitly call the AppEngine datastore Model constructor |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
337 |
db.Model.__init__(self, parent, key_name, app, **entity_values) |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
338 |
|
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
339 |
# call the Taggable constructor to initialize the tags specified as |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
340 |
# keyword arguments |
0ede2f3adbc1
Adds to Melange a tags framework based on taggable-mixin.
Madhusudan C.S <madhusudancs@gmail.com>
parents:
2407
diff
changeset
|
341 |
Taggable.__init__(self, task_type=TaskTypeTag, |
2858
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
342 |
difficulty=TaskDifficultyTag, |
9b59d89e6707
Added additional methods for TaskTag model and add arbit_tag type to GHOPTask.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
2788
diff
changeset
|
343 |
arbit_tag=TaskArbitraryTag) |