taskapp/models.py
author nishanth
Fri, 26 Feb 2010 18:34:30 +0530
changeset 123 a6b4234388c8
parent 119 39ab7c460143
child 124 6d92b7cd2a37
permissions -rw-r--r--
now notification depends on id and not pos.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
61
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
     1
import os
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
     2
61
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
     3
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
     4
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
     5
from django.contrib.auth.models import User
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
     6
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     7
import tagging
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     8
from tagging.fields import TagField
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
     9
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
    10
from pytask.taskapp.utilities.helper import get_key
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
    11
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
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
    13
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
    14
	("AD", "Admin"),
107
4903b4973fc8 completed the process_request part.
nishanth
parents: 104
diff changeset
    15
	("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
    16
	("DV", "Developer"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    17
	("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
    18
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
    19
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
    20
    ("UP", "Unpublished"),
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
    21
    ("OP", "Open"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    22
    ("LO", "Locked"),
63
1fc027bf99ee added events in task.py for adding subtask and dependencies
nishanth
parents: 61
diff changeset
    23
    ("WR", "Working"),
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    24
    ("CD", "Closed"),
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    25
    ("DL", "Deleted"),
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    26
    ("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
    27
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
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
    29
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
    30
118
5bbb29a07b87 modified image storage.
nishanth
parents: 116
diff changeset
    31
61
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    32
class CustomImageStorage(FileSystemStorage):
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    33
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    34
    def path(self, name):
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    35
        """ we return images directory path.
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    36
        """
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    37
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    38
        return os.path.join(IMAGES_DIR, name)
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    39
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    40
    def get_available_name(self, name):
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    41
        """ here we are going with username as the name of image.
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    42
        """
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    43
    
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    44
        root, ext = os.path.splitext(name)
118
5bbb29a07b87 modified image storage.
nishanth
parents: 116
diff changeset
    45
        file_name = get_key() + ext
5bbb29a07b87 modified image storage.
nishanth
parents: 116
diff changeset
    46
        while self.exists(file_name):
5bbb29a07b87 modified image storage.
nishanth
parents: 116
diff changeset
    47
            file_name = get_key() + ext
5bbb29a07b87 modified image storage.
nishanth
parents: 116
diff changeset
    48
        return file_name
61
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    49
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    50
class Profile(models.Model):
59
f6a3bf088a9e made changes to models.
anoop
parents: 58
diff changeset
    51
    
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
    52
    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
    53
    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
    54
    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
    55
    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
    56
    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
    57
    
12
a93eebabfeb1 created forms, views, templates, actions for home_page, browse_task.
nishanth
parents: 10
diff changeset
    58
    aboutme = models.TextField(blank = True)
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
    59
    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
    60
    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
    61
    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
    62
    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
    63
    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
    64
    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
    65
    nick = models.CharField(max_length = 20, blank = True)
61
708dd49d531b added custom image storage for profile photo.
nishanth
parents: 59
diff changeset
    66
    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
    67
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
    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
    69
        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
    70
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
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
    72
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
    73
    
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
    74
    prim_key = models.AutoField(primary_key = True)
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
    75
    id = models.CharField(max_length = 10, 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
    76
    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
    77
    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
    78
    status = models.CharField(max_length = 2, choices = STATUS_CHOICES, default = "UP")
49
52b774df918e fixed a bug in models.
anoop
parents: 48
diff changeset
    79
    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
    80
    
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
    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
    82
    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
    83
        
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    84
    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
    85
    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
    86
    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
    87
    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
    88
    
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
    89
    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
    90
    sub_type = models.CharField(max_length=1, choices = (('D','Dependency'),('S','Subtask')), default = 'D')   
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
    91
    
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
    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
    93
        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
    94
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
    95
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
    96
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
    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
    98
    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
    99
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
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
   101
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
   102
    
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
    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
   104
    data = models.TextField()
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
   105
    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
   106
    creation_datetime = models.DateTimeField()
59
f6a3bf088a9e made changes to models.
anoop
parents: 58
diff changeset
   107
    deleted_by = models.ForeignKey(User, null = True, blank = True, related_name = "%(class)s_deleted_by")
112
eadff01e395e now task page displays only undeleted comments. and publish task removes previous comments.
nishanth
parents: 107
diff changeset
   108
    is_deleted = models.BooleanField()
59
f6a3bf088a9e made changes to models.
anoop
parents: 58
diff changeset
   109
    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
   110
    
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
   111
    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
   112
        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
   113
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
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
   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
    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
   117
    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
   118
    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
   119
    points = models.PositiveSmallIntegerField()
10
bf0cbea1bd12 removed views.py and made it a package. added auth_profile to settings.py
nishanth
parents: 1
diff changeset
   120
    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
   121
    
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
   122
    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
   123
        return unicode(self.task.title)
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   124
        
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   125
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
   126
    
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   127
    task = models.ForeignKey('Task')
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   128
    user = models.ForeignKey(User)
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   129
    message = models.TextField()
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   130
    creation_datetime = models.DateTimeField()
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   131
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   132
class Request(models.Model):
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   133
85
9cf299c47990 changed request model.
anoop
parents: 83
diff changeset
   134
    sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False)
9cf299c47990 changed request model.
anoop
parents: 83
diff changeset
   135
    sent_by = models.ForeignKey(User, related_name = "%(class)s_sent_by", blank = False)
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   136
    role = models.CharField(max_length = 2, blank = False)
116
cb7f54ed5866 modified request model.
nishanth
parents: 115
diff changeset
   137
    reply = models.BooleanField(default = False, blank = False)
104
d1bdd5d6c1a6 added the field remarks in request model.
nishanth
parents: 90
diff changeset
   138
    remarks = models.TextField(default = "",blank = True)
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
   139
    
116
cb7f54ed5866 modified request model.
nishanth
parents: 115
diff changeset
   140
    is_read = models.BooleanField(default = False, blank = False)
cb7f54ed5866 modified request model.
nishanth
parents: 115
diff changeset
   141
    is_valid = models.BooleanField(default = True, blank = False)
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
   142
    
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   143
    creation_date = models.DateTimeField()
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   144
    reply_date = models.DateTimeField()
85
9cf299c47990 changed request model.
anoop
parents: 83
diff changeset
   145
    is_replied = models.BooleanField(default = False)
86
fcbdf372857c modified requests to match the new model.
nishanth
parents: 85
diff changeset
   146
    replied_by = models.ForeignKey(User, related_name = "%(class)s_replied_by", blank = True, null = True)
119
39ab7c460143 did lots and now id field in task is a random key
nishanth
parents: 118
diff changeset
   147
    
59
f6a3bf088a9e made changes to models.
anoop
parents: 58
diff changeset
   148
    task = models.ForeignKey(Task,related_name = "%(class)s_task", blank = True, null = True)
85
9cf299c47990 changed request model.
anoop
parents: 83
diff changeset
   149
    receiving_user = models.ForeignKey(User, related_name = "%(class)s_receiving_user", blank = True, null = True)
80
8917b190c4c4 added attribute pynts to request model.
anoop
parents: 71
diff changeset
   150
    pynts = models.PositiveIntegerField(default=0)
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   151
83
fd2e1bd7af82 added accept_assign_credits request
nishanth
parents: 80
diff changeset
   152
    def __unicode__(self):
fd2e1bd7af82 added accept_assign_credits request
nishanth
parents: 80
diff changeset
   153
86
fcbdf372857c modified requests to match the new model.
nishanth
parents: 85
diff changeset
   154
        return u"Request %s %s"%(self.sent_by.username, self.role)
83
fd2e1bd7af82 added accept_assign_credits request
nishanth
parents: 80
diff changeset
   155
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   156
class Notification(models.Model):
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   157
123
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   158
    sent_to = models.ManyToManyField(User, related_name = "%(class)s_sent_to", blank = False)
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   159
    sent_from = models.ManyToManyField(User, related_name = "%(class)s_sent_from", blank = True)
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   160
51
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   161
    sub = models.CharField(max_length = 100)
89463859712c added request and notification models.
nishanth
parents: 49
diff changeset
   162
    message = models.TextField()
123
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   163
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   164
    sent_date = models.DateTimeField()
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   165
    is_read = models.BooleanField(default = False)
a6b4234388c8 now notification depends on id and not pos.
nishanth
parents: 119
diff changeset
   166
    is_deleted = models.BooleanField(default = False)
21
c28774fe7ffd implemented "add another mentor" functionality to a task.
nishanth
parents: 18
diff changeset
   167
    
48
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
   168
tagging.register(Profile)
8670846be981 installed tagging into the app.
anoop
parents: 38
diff changeset
   169
tagging.register(Task)