def handle_mail(mail_dict): from inbox.models import Mail, Inbox """ Save mail to Inbox model. Check and apply handlig rules for email. """ inbox = get_object_or_None(Inbox, slug=mail_dict.pop('inbox')) if inbox: Mail.objects.new_mail(inbox, mail_dict)
def person(self): """ Return the user's :class:`Person` instance. """ from persons.models import Person return get_object_or_None(Person, user=self)
def get_inbox(self, user, **kwargs): """ Get inbox for given User """ queryset = self.get_query_set().filter(users=user).prefetch_related('users') return get_object_or_None(queryset, **kwargs)
def get_mail(self, user, **kwargs): queryset = self.get_user_mails(user).prefetch_related('readers') return get_object_or_None(queryset, **kwargs)
def _validate(self, username, password): # Get inbox, using credintails inbox = get_object_or_None(Inbox, slug=username, password=password) return True if inbox else False