Use keyword arguments in UserPresence.to_presence_dict()

Also rename the function, which was previously called to_presense_dict.

This will let us be more flexible about adding additional values.

(imported from commit 323b7d2df53918928190c9ee9544b4599a5e2df3)
This commit is contained in:
Luke Faraone
2014-02-14 16:45:32 -05:00
committed by Jessica McKellar
parent 0ac73e4d73
commit f30a62e33c

View File

@@ -1073,17 +1073,17 @@ class UserPresence(models.Model):
) )
for row in query: for row in query:
email = row['user_profile__email'] info = UserPresence.to_presence_dict(
client_name = row['client__name'] client_name=row['client__name'],
status = row['status'] status=row['status'],
timestamp = row['timestamp'] timestamp=row['timestamp'],
info = UserPresence.to_presense_dict(client_name, status, timestamp) )
user_statuses[email][client_name] = info user_statuses[row['user_profile__email']][row['client__name']] = info
return user_statuses return user_statuses
@staticmethod @staticmethod
def to_presense_dict(client_name, status, timestamp): def to_presence_dict(client_name=None, status=None, timestamp=None):
presence_val = UserPresence.status_to_string(status) presence_val = UserPresence.status_to_string(status)
timestamp = datetime_to_timestamp(timestamp) timestamp = datetime_to_timestamp(timestamp)
return dict( return dict(
@@ -1093,10 +1093,10 @@ class UserPresence(models.Model):
) )
def to_dict(self): def to_dict(self):
return UserPresence.to_presense_dict( return UserPresence.to_presence_dict(
self.client.name, client_name=self.client.name,
self.status, status=self.status,
self.timestamp timestamp=self.timestamp
) )
@staticmethod @staticmethod