Esempio n. 1
0
def notifications_delete(request):
    user1 = request.user
    notify(user1)
    for x in range(1, 5):
        notification.objects.filter(user=user1, category=x).delete()
    notification.objects.filter(user=user1, category=6).delete()
    return redirect('notices')
Esempio n. 2
0
 def get(self, request):
     user1 = request.user
     notify(user1)
     chat_unseen1 = chat_unseen.objects.get(user=user1)
     chat_unseen1.count = 0
     chat_unseen1.save()
     chatnotes = chat.objects.filter(sender=user1, noted=True).count()
     r_form = receiver()
     return render(request, self.template_name, {
         'r_form': r_form,
         'chatnotes': chatnotes
     })
Esempio n. 3
0
def notifications(request):
    user1 = request.user
    notify(user1)
    unseen = new_notes.objects.get(user=user1)
    unseen.count = 0
    unseen.save()
    notifications = notification.objects.filter(user=user1).order_by('-time')
    note_count = notification.objects.filter(user=user1).count()
    return render(request, 'Student/notification.html', {
        'notifications': notifications,
        'note_count': note_count
    })
Esempio n. 4
0
def home(request):
    user1 = request.user
    try:
        chat_unseen1 = chat_unseen.objects.get(user=user1)
    except chat_unseen.DoesNotExist:
        chat_unseen1 = chat_unseen(user=user1)
        chat_unseen1.save()
    try:
        bookseat = bookseats.objects.get(user=user1)
    except bookseats.DoesNotExist:
        bookseat = bookseats(user=user1)
        bookseat.save()
    try:
        unseen = new_notes.objects.get(user=user1)
    except new_notes.DoesNotExist:
        unseen = new_notes(user=user1)
        unseen.save()
    notify(user1)
    return render(request, 'Student/home.html')
Esempio n. 5
0
 def get(self, request, receiver_username):
     user1 = request.user
     notify(user1)
     if receiver_username == user1.username:
         messages.error(
             request,
             f'Sorry! Scientists are still trying to find a person exactly like you'
         )
         return redirect('chat')
     user2 = get_object_or_404(User, username=receiver_username)
     try:
         chat1 = chat.objects.get(sender=user1, receiver=user2.username)
         chat2 = chat.objects.get(sender=user2, receiver=user1.username)
     except chat.DoesNotExist:
         chat1 = chat(sender=user1, receiver=user2)
         chat1.save()
         chat2 = chat(sender=user2, receiver=user1)
         chat2.save()
     if chat1.noted == True:
         chat1.noted = False
         chat1.save()
     m_form = sendmessage()
     context = {'chat': chat1, 'm_form': m_form}
     return render(request, self.template_name, context)
Esempio n. 6
0
def gadgets(request):
    user1 = request.user
    notify(user1)
    gadget_count = gadget.objects.filter(user=user1).count()
    return render(request, 'Student/gadgets.html',
                  {'gadget_count': gadget_count})