taskapp/models.py
author anoop
Tue, 23 Feb 2010 15:27:00 +0530
changeset 58 e0ec1901dfce
parent 52 0b73f0d8e06e
child 59 f6a3bf088a9e
permissions -rw-r--r--
changed request model, added create_request utility.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
     1
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
     2
from django.contrib.auth.models import User
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     3
import tagging
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     4
from tagging.fields import TagField
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     5
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
     6
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
     7
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
     8
	("AD", "Admin"),
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
     9
	("MN", "Manager"),
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
	("DV", "Developer"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    11
	("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
    12
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
    13
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
    14
    ("UP", "Unpublished"),
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
    15
    ("OP", "Open"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    16
    ("LO", "Locked"),
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
    17
    ("CL", "Claimed"),
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
    18
    ("AS", "Assigned"),
22
36d3173ab7f9 addded link to view claims in 'view task' page .
nishanth
parents: 21
diff changeset
    19
    ("RE", "Reopened"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    20
    ("CD", "Closed"),
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    21
    ("DL", "Deleted"),
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    22
    ("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
    23
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
    24
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
    25
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
    26
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    27
class Profile(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
    28
	
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
    29
    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
    30
    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
    31
    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
    32
    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
    33
    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
    34
    
12
a93eebabfeb1 created forms, views, templates, actions for home_page, browse_task.
nishanth
parents: 10
diff changeset
    35
    aboutme = models.TextField(blank = True)
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
    36
#    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.")
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
    37
    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
    38
    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
    39
    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
    40
    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
    41
    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
    42
    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
    43
    nick = models.CharField(max_length = 20, blank = True)
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    44
#    photo = models.ImageField(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
    45
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
    46
    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
    47
        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
    48
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
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
    50
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
    51
    
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
    52
    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
    53
    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
    54
    status = models.CharField(max_length = 2, choices = STATUS_CHOICES, default = "UP")
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
    55
#    tags = models.CharField(max_length = 200, blank = True)
49
52b774df918e fixed a bug in models.
anoop
parents: 48
diff changeset
    56
    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
    57
    
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    58
    subs = models.ManyToManyField('self', blank = True, related_name = "%(class)s_parents")
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
    59
    deps = models.ManyToManyField('self', blank = True, related_name = "%(class)s_deps")
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
    
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
    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
    62
    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
    63
        
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    64
    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
    65
    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
    66
    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
    67
    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
    68
    
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    69
    creation_datetime = 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
    70
    
12
a93eebabfeb1 created forms, views, templates, actions for home_page, browse_task.
nishanth
parents: 10
diff changeset
    71
    #is_claimable = models.BooleanField()
a93eebabfeb1 created forms, views, templates, actions for home_page, browse_task.
nishanth
parents: 10
diff changeset
    72
    
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
    73
    ## 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
    74
    ## 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
    75
    ## 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
    76
    
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
    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
    78
        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
    79
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
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
    81
    
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
    82
    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
    83
    data = models.TextField()
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    84
    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
    85
    creation_datetime = models.DateTimeField()
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    86
#    deleted_by = models.ForeignKey(User, null = True, blank = True, related_name = "%(class)s_deleted_by")
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    87
#    deleted = models.BooleanField()
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    88
#    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
    89
    
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
    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
    91
        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
    92
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
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
    94
    
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
    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
    96
    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
    97
    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
    98
    points = models.PositiveSmallIntegerField()
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    99
    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
   100
    
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
   101
    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
   102
        return unicode(self.task.title)
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   103
        
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   104
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
   105
    
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   106
    task = models.ForeignKey('Task')
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   107
    user = models.ForeignKey(User)
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   108
    message = models.TextField()
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   109
    creation_datetime = models.DateTimeField()
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   110
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   111
class Request(models.Model):
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   112
58
e0ec1901dfce changed request model, added create_request utility.
anoop
parents: 52
diff changeset
   113
    to = models.ManyToManyField(User, related_name = "%(class)s_to", blank = False)
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   114
    by = models.ForeignKey(User, related_name = "%(class)s_by", blank = False)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   115
    role = models.CharField(max_length = 2, blank = False)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   116
    is_active = models.BooleanField(default = True)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   117
    reply = models.BooleanField(default = False)
58
e0ec1901dfce changed request model, added create_request utility.
anoop
parents: 52
diff changeset
   118
    read = models.BooleanField(default = False)
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   119
    creation_date = models.DateTimeField()
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   120
    reply_date = models.DateTimeField()
58
e0ec1901dfce changed request model, added create_request utility.
anoop
parents: 52
diff changeset
   121
    replied = models.BooleanField(default = False)
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   122
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   123
class Notification(models.Model):
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   124
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   125
    to = models.ManyToManyField(User, related_name = "%(class)s_to", blank = False)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   126
    is_read = models.BooleanField(default = False)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   127
    sent_date = models.DateTimeField()
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   128
    sub = models.CharField(max_length = 100)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   129
    message = models.TextField()
52
0b73f0d8e06e fixed a bug in models.py .
nishanth
parents: 51
diff changeset
   130
    deleted = models.BooleanField(default = False)
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   131
    
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
   132
tagging.register(Profile)
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
   133
tagging.register(Task)