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:
email = row['user_profile__email']
client_name = row['client__name']
status = row['status']
timestamp = row['timestamp']
info = UserPresence.to_presense_dict(client_name, status, timestamp)
user_statuses[email][client_name] = info
info = UserPresence.to_presence_dict(
client_name=row['client__name'],
status=row['status'],
timestamp=row['timestamp'],
)
user_statuses[row['user_profile__email']][row['client__name']] = info
return user_statuses
@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)
timestamp = datetime_to_timestamp(timestamp)
return dict(
@@ -1093,10 +1093,10 @@ class UserPresence(models.Model):
)
def to_dict(self):
return UserPresence.to_presense_dict(
self.client.name,
self.status,
self.timestamp
return UserPresence.to_presence_dict(
client_name=self.client.name,
status=self.status,
timestamp=self.timestamp
)
@staticmethod