Example #1
0
    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)

        if get_user(self.request) is not None:
            curUser = get_user(self.request)
            context['curUser'] = curUser.email_address
        return context
Example #2
0
    def get_object(self):
        other_username = self.kwargs.get("username")
        if get_user(self.request) is not None:
            user = get_user(self.request)

        obj, created = Thread.objects.get_or_new(user, other_username)
        if obj is None:
            raise Http404
        return obj
Example #3
0
    def form_valid(self, form):
        thread = self.get_object()
        user = None

        if get_user(self.request) is not None:
            user = get_user(self.request)

        message = form.cleaned_data.get("message")
        ChatMessage.objects.create(user=user, thread=thread, message=message)
        return super().form_valid(form)
Example #4
0
def signed_in(request):
    logged_in = check_user_token_validation(request)
    if logged_in:
        try:
            user = get_user(request)
        except:
            return logged_in
    return render(request, "patientDashboard.html")
Example #5
0
def go_to_chat(request):
    print(request.GET.get("doctor_id"))
    doctor_id = request.GET.get("doctor_id")
    doctor = DoctorModel.objects.filter(id=doctor_id).first()
    print(doctor)
    logged_in = check_user_token_validation(request)
    user = None
    if logged_in:
        try:
            user = get_user(request)
        except:
            return logged_in
    new_consultation = Consultation(doctor=doctor, user=user, no_days=1)
    new_consultation.save()
    return HttpResponseRedirect("consultations/" + doctor.email_address + "/")
Example #6
0
 def dispatch(self, request, *args, **kwargs):
     if get_user(request) is None:
         messages.error(request, 'Please log in first to access Inbox.')
         return HttpResponseRedirect('/login')
     else:
         return super(ThreadView, self).dispatch(request, *args, **kwargs)
Example #7
0
 def get_queryset(self):
     user = None
     if get_user(self.request) is not None:
         user = get_user(self.request)
     return Thread.objects.by_user(user)