Skip to content

Commit

Permalink
rename event attribute from "user" to "account"
Browse files Browse the repository at this point in the history
  • Loading branch information
pudo committed Jul 13, 2011
1 parent b22071b commit b9c8200
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions datahub/model/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ class Event(db.Model):
message = db.Column(db.UnicodeText)
time = db.Column(db.DateTime, default=datetime.utcnow)

user_id = db.Column(db.Integer, db.ForeignKey('account.id'))
user = db.relationship(Account,
account_id = db.Column(db.Integer, db.ForeignKey('account.id'))
account = db.relationship(Account,
backref=db.backref('events', lazy='dynamic'))

data = db.Column(JSONType, default=dict)

def __init__(self, user, message):
self.user = user
def __init__(self, account, message):
self.account = account
self.message = message

def to_dict(self):
Expand All @@ -29,7 +29,7 @@ def to_dict(self):
'time': self.time,
'data': self.data,
'type': self.discriminator,
'user': self.user.name}
'account': self.account.name}


class EventStreamEntry(db.Model):
Expand All @@ -55,18 +55,21 @@ def to_dict(self):
'type': self.discriminator,
'event': self.event.to_dict()}


##### Event types library

class AccountCreatedEvent(Event):
__mapper_args__ = {'polymorphic_identity': 'account_created'}

def __init__(self, user):
super(AccountCreatedEvent, self).__init__(user, '')
def __init__(self, account):
super(AccountCreatedEvent, self).__init__(account, '')

class ResourceCreatedEvent(Event):
__mapper_args__ = {'polymorphic_identity': 'resource_created'}

def __init__(self, user, resource):
super(ResourceCreatedEvent, self).__init__(user, resource.summary)
self.data = {'resource': resource.name}
def __init__(self, account, resource):
super(ResourceCreatedEvent, self).__init__(account,
resource.summary)
self.data = {'resource': resource.name,
'owner': account.name}

0 comments on commit b9c8200

Please sign in to comment.