~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/answers/model/questionsubscription.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-02 07:06:41 UTC
  • mfrom: (13487.1.22 question-subscribe-187093)
  • Revision ID: launchpad@pqm.canonical.com-20110802070641-dio19795653pzedo
[r=sinzui][bug=187093] Add ajax subscription support to the
        subscribers portal.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
 
10
10
__all__ = ['QuestionSubscription']
11
11
 
 
12
import pytz
 
13
 
12
14
from sqlobject import ForeignKey
 
15
from storm.locals import (
 
16
    DateTime,
 
17
    Int,
 
18
    )
13
19
from zope.interface import implements
14
20
 
 
21
from canonical.database.constants import UTC_NOW
15
22
from canonical.database.sqlbase import SQLBase
16
23
from lp.answers.interfaces.questionsubscription import IQuestionSubscription
17
24
from lp.registry.interfaces.person import validate_public_person
25
32
 
26
33
    _table = 'QuestionSubscription'
27
34
 
 
35
    id = Int(primary=True)
 
36
    question_id = Int("question", allow_none=False)
28
37
    question = ForeignKey(
29
38
        dbName='question', foreignKey='Question', notNull=True)
30
39
 
 
40
    person_id = Int(
 
41
        "person", allow_none=False, validator=validate_public_person)
31
42
    person = ForeignKey(
32
43
        dbName='person', foreignKey='Person',
33
44
        storm_validator=validate_public_person, notNull=True)
34
45
 
 
46
    date_created = DateTime(
 
47
        allow_none=False, default=UTC_NOW, tzinfo=pytz.UTC)
 
48
 
35
49
    def canBeUnsubscribedByUser(self, user):
36
50
        """See `IQuestionSubscription`."""
37
51
        if user is None: