app/soc/models/notification.py
author Lennard de Rijk <ljvderijk@gmail.com>
Sat, 10 Jan 2009 13:28:04 +0000
changeset 794 19c24508c398
parent 756 a0c0b48563cb
child 824 e964dca75527
permissions -rw-r--r--
Added _readonly_field_as_twoline_table_row . Patch by: Lennard de Rijk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
726
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     1
#!/usr/bin/python2.5
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     2
#
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     3
# Copyright 2008 the Melange authors.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     4
#
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     5
# Licensed under the Apache License, Version 2.0 (the "License");
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     6
# you may not use this file except in compliance with the License.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     7
# You may obtain a copy of the License at
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     8
# 
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
     9
#   http://www.apache.org/licenses/LICENSE-2.0
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    10
# 
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    11
# Unless required by applicable law or agreed to in writing, software
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    12
# distributed under the License is distributed on an "AS IS" BASIS,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    14
# See the License for the specific language governing permissions and
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    15
# limitations under the License.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    16
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    17
"""This module contains the Notification Model.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    18
"""
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    19
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    20
__authors__ = [
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    21
  '"Lennard de Rijk" <ljvderijk@gmail.com>',
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    22
]
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    23
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    24
from google.appengine.ext import db
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    25
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    26
from django.utils.translation import ugettext_lazy
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    27
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    28
import soc.models.linkable
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    29
import soc.models.user
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    30
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    31
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    32
class Notification(soc.models.linkable.Linkable):
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    33
  """Model of a Notification.
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    34
  """
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    35
748
f00e6b3af5a6 Remove unused imports in models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 737
diff changeset
    36
  #: a reference to the user this Notification is from
f00e6b3af5a6 Remove unused imports in models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 737
diff changeset
    37
  #: this is a non-required property, None will indicate an Anonymous Admin
726
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    38
  from_user = db.ReferenceProperty(reference_class=soc.models.user.User,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    39
      required=False,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    40
      collection_name="sent_notifications",
756
a0c0b48563cb Changed invitation email and into a notification.
Lennard de Rijk <ljvderijk@gmail.com>
parents: 748
diff changeset
    41
      verbose_name=ugettext_lazy('From'))
726
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    42
  
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    43
  subject = db.StringProperty(required=True,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    44
      verbose_name=ugettext_lazy('Subject'))
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    45
  
748
f00e6b3af5a6 Remove unused imports in models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 737
diff changeset
    46
  #: the message that is contained within this Notification
726
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    47
  message = db.TextProperty(required=True,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    48
      verbose_name=ugettext_lazy('Message'))
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    49
  
748
f00e6b3af5a6 Remove unused imports in models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 737
diff changeset
    50
  #: date and time on which this Notification was created
726
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    51
  created_on = db.DateTimeProperty(auto_now_add=True,
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    52
      verbose_name=ugettext_lazy('Created On'))
ba3d399ec9be Added Notifications.
Lennard de Rijk <ljvderijk@gmail.com>
parents:
diff changeset
    53
  
748
f00e6b3af5a6 Remove unused imports in models modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents: 737
diff changeset
    54
  #: boolean property that marks if the notification is unread
737
4c78ee183eb6 Notification property has_been_read changed into unread
Lennard de Rijk <ljvderijk@gmail.com>
parents: 726
diff changeset
    55
  unread = db.BooleanProperty(default=True,
4c78ee183eb6 Notification property has_been_read changed into unread
Lennard de Rijk <ljvderijk@gmail.com>
parents: 726
diff changeset
    56
      verbose_name=ugettext_lazy('Unread'))