Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sent box and/or ThreadStart model #54

Open
tarsil opened this issue Apr 29, 2020 · 0 comments
Open

Add sent box and/or ThreadStart model #54

tarsil opened this issue Apr 29, 2020 · 0 comments

Comments

@tarsil
Copy link

tarsil commented Apr 29, 2020

Is your feature request related to a problem? Please describe.
Adding a concept of the sent box or something that allows knowing who started a thread in the first place.

Describe the solution you'd like
Adding a concept of a sent box it would help to understand which conversations you have started and map better.

For the ThreadStart:

import uuid as _uuid

class ThreadStart(models.Model):
    uuid = models.UUIDField(editable=False, null=False, blank=False, default=_uuid)
    thread = models.ForeignKey(Thread, related_name="threads_started", null=False, blank=False, on_delete =models.CASCADE)
    sender = models.ForeignKey(AUTH_USER_MODEL, related_name="threads_started", null=False, blank=False, on_delete=models.CASCADE)

    def __str__(self):
         return "User: {} - Thread: {}".format(self.sender, self.thread)

For the sent box without thread start:

    @classmethod
    def sent(cls, user):
        """
        Returns the sent message folder
        :param user: User to check the sent messages
        :return:
        """
        ids = [t.pk for t in cls.objects.filter(userthread__user=user, userthread__deleted=False)
               if t.is_user_first_message(user)]
        return cls.objects.filter(userthread__user=user, userthread__deleted=False, pk__in=ids)

Sent box with thread start

@classmethod
def sent(cls, user):
    """
    Returns the sent message folder
    :param user: User to check the sent messages
    :return:
    """
    return cls.objects.filter(threads_started__user=user, userthread__deleted=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant