author | Lennard de Rijk <ljvderijk@gmail.com> |
Sun, 25 Oct 2009 18:43:23 -0700 | |
changeset 3050 | 5f135cfac194 |
parent 3046 | cd08e035ac9e |
permissions | -rw-r--r-- |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
1 |
#!/usr/bin/python2.5 |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
2 |
# |
1308
35b75ffcbb37
Partially reverted "Update the copyright notice for 2009."
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1307
diff
changeset
|
3 |
# Copyright 2008 the Melange authors. |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
4 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
6 |
# you may not use this file except in compliance with the License. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
7 |
# You may obtain a copy of the License at |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
8 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
10 |
# |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
11 |
# Unless required by applicable law or agreed to in writing, software |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
14 |
# See the License for the specific language governing permissions and |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
15 |
# limitations under the License. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
16 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
17 |
"""This module contains the Request Model.""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
18 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
19 |
__authors__ = [ |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
20 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
928
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
21 |
'"Lennard de Rijk" <ljvderijk@gmail.com>', |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
22 |
] |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
23 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
24 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
25 |
from google.appengine.ext import db |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
26 |
|
970
8b5611d5b053
Use ugettext instead of ugettext_lazy
Sverre Rabbelier <srabbelier@gmail.com>
parents:
959
diff
changeset
|
27 |
from django.utils.translation import ugettext |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
28 |
|
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
29 |
from soc.models.base import ModelWithFieldAttributes |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
30 |
from soc.models.group import Group |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
31 |
from soc.models.user import User |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
32 |
|
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
33 |
|
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
34 |
class Request(ModelWithFieldAttributes): |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
35 |
"""A request is made to allow a person to create a new Role entity. |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
36 |
""" |
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
37 |
|
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
38 |
#: The internal name of the role |
915
27c656c01591
Added verbose role name to the request model.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
562
diff
changeset
|
39 |
role = db.StringProperty(required=True) |
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
40 |
|
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
41 |
#: The user this request is from |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
42 |
user = db.ReferenceProperty( |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
43 |
reference_class=User, |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
44 |
required=True, collection_name='requests', |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
45 |
verbose_name=ugettext('User')) |
928
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
46 |
|
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
47 |
#: The group this request is for |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
48 |
group = db.ReferenceProperty( |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
49 |
reference_class=Group, |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
50 |
required=True, collection_name='requests', |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
51 |
verbose_name=ugettext('Group')) |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
52 |
|
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
53 |
#: An optional message shown to the receiving end of this request |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
54 |
message = db.TextProperty(required=False, default='', |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
55 |
verbose_name=ugettext("Message")) |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
56 |
message.help_text = ugettext( |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
57 |
'This is an optional message shown to the receiver of this request.') |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
58 |
|
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
970
diff
changeset
|
59 |
# property that determines the status of the request |
928
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
60 |
# new : new Request |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
61 |
# group_accepted : The group has accepted this request |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
62 |
# completed : This request has been handled either following a creation of |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
63 |
# the role entity |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
64 |
# rejected : This request has been rejected by either the user or the group |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
65 |
# ignored : The request has been ignored by the group and will not give |
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
66 |
# the user access to create the role |
1085
0afbdd0905ef
Renamed state to status where appropriate.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
970
diff
changeset
|
67 |
status = db.StringProperty(required=True, default='new', |
928
df051fc9d7a1
Replaced the boolean properties in soc/models/request.py with a state property.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
915
diff
changeset
|
68 |
choices=['new', 'group_accepted', 'completed', 'rejected','ignored']) |
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
69 |
status.help_text = ugettext('Shows the status of the request.') |
495
87afae6e4c51
Added basic 'invite' functionality
Sverre Rabbelier <srabbelier@gmail.com>
parents:
diff
changeset
|
70 |
|
1686
d9cc9f8ca19f
Added created_on DateTime property to request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1308
diff
changeset
|
71 |
#: DateTime when the request was created |
d9cc9f8ca19f
Added created_on DateTime property to request.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1308
diff
changeset
|
72 |
created_on = db.DateTimeProperty(auto_now_add=True) |
3046
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
73 |
|
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
74 |
#: DateTime when this request was last modified |
cd08e035ac9e
Redone the Request object to contain a message property and work on ID-basis.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
1686
diff
changeset
|
75 |
modified_on = db.DateTimeProperty(auto_now=True) |