get_old_messages: Refactor handling of UserMessage flags.

This is in preparation for having a case in which we query the
database directly to get the message flags, without going through a
UserMessage object.

(imported from commit d5218974680b0c4b028a84f3aae1c8242ceb08ce)
This commit is contained in:
Tim Abbott
2013-06-19 15:05:22 -04:00
parent e5e0544816
commit a8d86d5fb2
2 changed files with 13 additions and 12 deletions

View File

@@ -406,9 +406,11 @@ class UserMessage(models.Model):
display_recipient = get_display_recipient(self.message.recipient)
return (u"<UserMessage: %s / %s (%s)>" % (display_recipient, self.user_profile.email, self.flags_dict())).encode("utf-8")
def flags_dict(self):
return dict(flags = [flag for flag in self.flags.keys() if getattr(self.flags, flag).is_set])
def flags_list(self):
return [flag for flag in self.flags.keys() if getattr(self.flags, flag).is_set]
def flags_dict(self):
return dict(flags = [self.flags_list()])
class Subscription(models.Model):
user_profile = models.ForeignKey(UserProfile)