author | nishanth |
Fri, 26 Feb 2010 01:13:14 +0530 | |
changeset 107 | 4903b4973fc8 |
parent 104 | d1bdd5d6c1a6 |
child 112 | eadff01e395e |
permissions | -rw-r--r-- |
61 | 1 |
import random |
2 |
import string |
|
3 |
import os |
|
4 |
from django.core.files.storage import FileSystemStorage |
|
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
5 |
from django.db import models |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
6 |
from django.contrib.auth.models import User |
48 | 7 |
import tagging |
8 |
from tagging.fields import TagField |
|
9 |
||
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
10 |
GENDER_CHOICES = (( 'M', 'Male'), ('F', 'Female')) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
11 |
RIGHTS_CHOICES = ( |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
12 |
("AD", "Admin"), |
107 | 13 |
("MG", "Manager"), |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
14 |
("DV", "Developer"), |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
15 |
("CT", "Contributor"),) |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
16 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
17 |
STATUS_CHOICES = ( |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
18 |
("UP", "Unpublished"), |
51 | 19 |
("OP", "Open"), |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
20 |
("LO", "Locked"), |
63
1fc027bf99ee
added events in task.py for adding subtask and dependencies
nishanth
parents:
61
diff
changeset
|
21 |
("WR", "Working"), |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
22 |
("CD", "Closed"), |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
23 |
("DL", "Deleted"), |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
24 |
("CM", "Completed")) |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
25 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
26 |
IMAGES_DIR = "./images" |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
27 |
UPLOADS_DIR = "./uploads" |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
28 |
|
61 | 29 |
class CustomImageStorage(FileSystemStorage): |
30 |
||
31 |
def path(self, name): |
|
32 |
""" we return images directory path. |
|
33 |
""" |
|
34 |
||
35 |
return os.path.join(IMAGES_DIR, name) |
|
36 |
||
37 |
def get_available_name(self, name): |
|
38 |
""" here we are going with username as the name of image. |
|
39 |
""" |
|
40 |
||
41 |
root, ext = os.path.splitext(name) |
|
42 |
name = ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)])+ext |
|
43 |
while self.exists(name): |
|
44 |
name = ''.join([ random.choice(string.uppercase+string.digits) for i in range(10)])+ext |
|
45 |
return name |
|
46 |
||
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
47 |
class Profile(models.Model): |
59 | 48 |
|
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
49 |
user = models.ForeignKey(User, unique = True) |
38
7910ff503036
added help_text and verbose_name to models where required and removed import of seed_db from urls.py
nishanth
parents:
33
diff
changeset
|
50 |
dob = models.DateField(verbose_name = u"Date of Birth", help_text = "YYYY-MM-DD") |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
51 |
gender = models.CharField(max_length = 1, choices = GENDER_CHOICES) |
12
a93eebabfeb1
created forms, views, templates, actions for home_page, browse_task.
nishanth
parents:
10
diff
changeset
|
52 |
rights = models.CharField(max_length = 2, choices = RIGHTS_CHOICES, default = u"CT") |
a93eebabfeb1
created forms, views, templates, actions for home_page, browse_task.
nishanth
parents:
10
diff
changeset
|
53 |
credits = models.PositiveSmallIntegerField(default = 0) |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
54 |
|
12
a93eebabfeb1
created forms, views, templates, actions for home_page, browse_task.
nishanth
parents:
10
diff
changeset
|
55 |
aboutme = models.TextField(blank = True) |
48 | 56 |
# foss_comm = models.CharField(max_length = 80, blank = True, verbose_name = u"Foss Communities", help_text = u"Comma seperated list of foss communities you are involved in.") |
57 |
foss_comm = TagField() |
|
38
7910ff503036
added help_text and verbose_name to models where required and removed import of seed_db from urls.py
nishanth
parents:
33
diff
changeset
|
58 |
phonenum = models.CharField(max_length = 15, blank = True, verbose_name = u"Phone Number") |
7910ff503036
added help_text and verbose_name to models where required and removed import of seed_db from urls.py
nishanth
parents:
33
diff
changeset
|
59 |
homepage = models.URLField(blank = True, verbose_name = u"Homepage/Blog") |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
60 |
street = models.CharField(max_length = 80, blank = True) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
61 |
city = models.CharField(max_length = 25, blank = True) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
62 |
country = models.CharField(max_length = 25, blank = True) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
63 |
nick = models.CharField(max_length = 20, blank = True) |
61 | 64 |
photo = models.ImageField(storage = CustomImageStorage(),upload_to = IMAGES_DIR, blank = True) |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
65 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
66 |
def __unicode__(self): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
67 |
return unicode(self.user.username) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
68 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
69 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
70 |
class Task(models.Model): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
71 |
|
38
7910ff503036
added help_text and verbose_name to models where required and removed import of seed_db from urls.py
nishanth
parents:
33
diff
changeset
|
72 |
title = models.CharField(max_length = 100, unique = True, verbose_name = u"Title", help_text = u"Keep it simple and below 100 chars.") |
7910ff503036
added help_text and verbose_name to models where required and removed import of seed_db from urls.py
nishanth
parents:
33
diff
changeset
|
73 |
desc = models.TextField(verbose_name = u"Description") |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
74 |
status = models.CharField(max_length = 2, choices = STATUS_CHOICES, default = "UP") |
48 | 75 |
# tags = models.CharField(max_length = 200, blank = True) |
49 | 76 |
tags_field = TagField() |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
77 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
78 |
credits = models.PositiveSmallIntegerField() |
18
a39549bd5b08
implemented create task view which needed task.py in events. added a method show_msg to views/user.py and used it in logoff view.
nishanth
parents:
12
diff
changeset
|
79 |
progress = models.PositiveSmallIntegerField(default = 0) |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
80 |
|
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
81 |
mentors = models.ManyToManyField(User, related_name = "%(class)s_mentors") |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
82 |
created_by = models.ForeignKey(User, related_name = "%(class)s_created_by") |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
83 |
claimed_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_claimed_users") |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
84 |
assigned_users = models.ManyToManyField(User, blank = True, related_name = "%(class)s_assigned_users") |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
85 |
|
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
86 |
creation_datetime = models.DateTimeField() |
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
87 |
sub_type = models.CharField(max_length=1, choices = (('D','Dependency'),('S','Subtask')), default = 'D') |
12
a93eebabfeb1
created forms, views, templates, actions for home_page, browse_task.
nishanth
parents:
10
diff
changeset
|
88 |
#is_claimable = models.BooleanField() |
a93eebabfeb1
created forms, views, templates, actions for home_page, browse_task.
nishanth
parents:
10
diff
changeset
|
89 |
|
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
90 |
## not yet decided if attribs after this are to be included |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
91 |
## tasktype = "" ## "bugfix"/"enhancement" |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
92 |
## priority = "" ## "very urgent"/"urgent" |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
93 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
94 |
def __unicode__(self): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
95 |
return unicode(self.title) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
96 |
|
90
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
97 |
class Map(models.Model): |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
98 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
99 |
main = models.ForeignKey('Task', related_name = "%(class)s_main") |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
100 |
subs = models.ManyToManyField('Task', blank = True, null = True, related_name = "%(class)s_subs") |
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
101 |
|
b2426897ff18
our task model does not meet out needs. so modified it and added a model called map. made the changes in views accordingly.phew!!!. this one took the hell out of me :( .
nishanth
parents:
86
diff
changeset
|
102 |
|
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
103 |
class Comment(models.Model): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
104 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
105 |
task = models.ForeignKey('Task') |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
106 |
data = models.TextField() |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
107 |
created_by = models.ForeignKey(User, related_name = "%(class)s_created_by") |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
108 |
creation_datetime = models.DateTimeField() |
59 | 109 |
deleted_by = models.ForeignKey(User, null = True, blank = True, related_name = "%(class)s_deleted_by") |
110 |
deleted = models.BooleanField() |
|
111 |
attachment = models.FileField(upload_to = UPLOADS_DIR, blank = True) |
|
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
112 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
113 |
def __unicode__(self): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
114 |
return unicode(self.task.title) |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
115 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
116 |
class Credit(models.Model): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
117 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
118 |
task = models.ForeignKey('Task') |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
119 |
given_by = models.ForeignKey(User, related_name = "%(class)s_given_by") |
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
120 |
given_to = models.ForeignKey(User, related_name = "%(class)s_given_to") |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
121 |
points = models.PositiveSmallIntegerField() |
10
bf0cbea1bd12
removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents:
1
diff
changeset
|
122 |
given_time = models.DateTimeField() |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
123 |
|
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
124 |
def __unicode__(self): |
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
125 |
return unicode(self.task.title) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
126 |
|
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
127 |
class Claim(models.Model): |
1
7818992cbf83
Created taskapp and added data to models.py and edited settings.py to make it usable in admin interface.
Nishanth <nishanth@fossee.in>
parents:
diff
changeset
|
128 |
|
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
129 |
task = models.ForeignKey('Task') |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
130 |
user = models.ForeignKey(User) |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
131 |
message = models.TextField() |
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
132 |
creation_datetime = models.DateTimeField() |
51 | 133 |
|
134 |
class Request(models.Model): |
|
135 |
||
85 | 136 |
sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False) |
137 |
sent_by = models.ForeignKey(User, related_name = "%(class)s_sent_by", blank = False) |
|
51 | 138 |
role = models.CharField(max_length = 2, blank = False) |
139 |
reply = models.BooleanField(default = False) |
|
104 | 140 |
remarks = models.TextField(default = "",blank = True) |
85 | 141 |
is_read = models.BooleanField(default = False) |
51 | 142 |
creation_date = models.DateTimeField() |
143 |
reply_date = models.DateTimeField() |
|
85 | 144 |
is_replied = models.BooleanField(default = False) |
86 | 145 |
replied_by = models.ForeignKey(User, related_name = "%(class)s_replied_by", blank = True, null = True) |
59 | 146 |
task = models.ForeignKey(Task,related_name = "%(class)s_task", blank = True, null = True) |
85 | 147 |
receiving_user = models.ForeignKey(User, related_name = "%(class)s_receiving_user", blank = True, null = True) |
80 | 148 |
pynts = models.PositiveIntegerField(default=0) |
51 | 149 |
|
83 | 150 |
def __unicode__(self): |
151 |
||
86 | 152 |
return u"Request %s %s"%(self.sent_by.username, self.role) |
83 | 153 |
|
51 | 154 |
class Notification(models.Model): |
155 |
||
156 |
to = models.ManyToManyField(User, related_name = "%(class)s_to", blank = False) |
|
157 |
is_read = models.BooleanField(default = False) |
|
158 |
sent_date = models.DateTimeField() |
|
159 |
sub = models.CharField(max_length = 100) |
|
160 |
message = models.TextField() |
|
52 | 161 |
deleted = models.BooleanField(default = False) |
21
c28774fe7ffd
implemented "add another mentor" functionality to a task.
nishanth
parents:
18
diff
changeset
|
162 |
|
48 | 163 |
tagging.register(Profile) |
164 |
tagging.register(Task) |