<commit_before>from C4CApplication.models import *
from django.core.exceptions import PermissionDenied
from django.views.generic import ListView


from C4CApplication.views.utils import create_user
from C4CApplication.meta.user import User


class ListMessages(ListView):
    model = Message
    template_name = "C4CApplication/listMessages.html"
    paginate_by = 5
    
    def dispatch(self, request, *args, **kwargs):
        if 'email' not in self.request.session:
            raise PermissionDenied  # HTTP 403
        self.user = create_user(self.request.session['email'])
        return super(ListMessages, self).dispatch(request, *args, **kwargs)
    
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        context['received'] = self.received
        context['member'] = self.user.db_member
        return context
    
    def get(self, request, *args, **kwargs):
        self.received = kwargs['received']
        return super(ListMessages, self).get(request, *args, **kwargs)
<commit_msg>affiche les messages<commit_after>from C4CApplication.models import *
from django.core.exceptions import PermissionDenied
from django.views.generic import ListView


from C4CApplication.views.utils import create_user
from C4CApplication.meta.user import User


class ListMessages(ListView):
    model = Message
    template_name = "C4CApplication/listMessages.html"
    paginate_by = 5
    
    def dispatch(self, request, *args, **kwargs):
        if 'email' not in self.request.session:
            raise PermissionDenied  # HTTP 403
        self.user = create_user(self.request.session['email'])
        return super(ListMessages, self).dispatch(request, *args, **kwargs)
    
    def get_queryset(self):
        if self.received is '1':
            retour = Mailbox.objects.filter(member_receiver = self.user.db_member)
            x = []
            for mailbox in retour:
                x.append(mailbox.message)
            return x
        else:
            return Message.objects.filter(member_sender = self.user.db_member)
    
    def get_context_data(self, **kwargs):
        context = ListView.get_context_data(self, **kwargs)
        context['received'] = self.received
        context['member'] = self.user.db_member
        return context
    
    def get(self, request, *args, **kwargs):
        self.received = kwargs['received']
        return super(ListMessages, self).get(request, *args, **kwargs)

{'fraction_non_alphanumeric': 0.10226354082457559, 'fraction_numerical': 0.0068714632174616, 'mean_word_length': 3.077429983525535, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3622608', 'n_tokens_mistral': 717, 'n_tokens_neox': 693, 'n_words': 167}