Beispiel #1
0
def appointment_form(request):
    if request.method == 'POST':
        # create a form instance and populate it with data from the request:
        form = AppointmentForm(request.POST)
	
        if form.is_valid():
            
            name = str(form.cleaned_data['name'])
            doctor = str(form.cleaned_data['doctor'])
            problem = str(form.cleaned_data['problem'])
            date = str(form.cleaned_data['date'])
            time = str(form.cleaned_data['time'])
            contact = str(form.cleaned_data['contact'])
            email = str(form.cleaned_data['email'])
            cc_myself = form.cleaned_data['cc_myself']
            recipients = ['*****@*****.**', '*****@*****.**']
            if cc_myself:
                recipients.append(email)
            send_mail('Dent Studio APPOINTMENT REQUEST', '\nИмя пациента: '+name+'\nЗапись к врачу: '+doctor+'\nПричина записи: '+problem+'\nПредпочтительная дата приема: '+date+'\nПредпочтительное время приема: '+time+'\nКонтактный телефон: '+contact+'\nЭлектронная почта: '+email, '*****@*****.**', recipients)
            return render(request, 'appointment/sent_ok.html')
        else:
            return render(request, 'appointment/appointment.html', {'form': form})
    else:
        form = AppointmentForm()

        return render(request, 'appointment/appointment.html', {'form': form})
Beispiel #2
0
def department(request, department_id):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    current_department = Department.objects.get(id=department_id)
    doctors_set = Doctor.objects.filter(department=current_department)
    department_set = Department.objects.all()
    news_set = News.objects.all().order_by('-interest', '?')[:3]

    current_services_ids = current_department.pricelist_set.values_list(
        'service', flat=True).annotate(n=Count("id"))[::1]
    current_services = Service.objects.filter(id__in=current_services_ids)

    doctors = get_doctor_pairs(doctors_set)
    excell_price = ExcellPrice.objects.get(is_actual=True)

    return render(
        request, 'department.html', {
            "department": current_department,
            "id": department_id,
            "services": current_services,
            "departments": department_set,
            "doctors": doctors,
            "articles": news_set,
            "price_file": excell_price
        })
Beispiel #3
0
def faq(request, department_id=None):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    if department_id is None:
        department_id = Department.objects.all()[0].id

    departments = Department.objects.all()

    questions = Question.objects.filter(department_id=department_id).all()
    paginator = Paginator(questions, 9, orphans=3)
    page = request.GET.get('page')
    try:
        articles = paginator.page(page)
    except PageNotAnInteger:
        articles = paginator.page(1)
    except EmptyPage:
        articles = paginator.page(paginator.num_pages)

    return render(request, 'faq.html', {
        "articles": articles,
        "departments": departments
    })
Beispiel #4
0
def reviews(request):
    reviews_set = Review.objects.filter(is_active=True).order_by('date')
    department_set = Department.objects.all()

    review_form = ReviewForm(request.POST or None)
    if request.method == 'POST' and review_form.is_valid():
        review_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    paginator = Paginator(reviews_set, 4, orphans=2)
    page = request.GET.get('page')
    try:
        articles = paginator.page(page)
    except PageNotAnInteger:
        articles = paginator.page(1)
    except EmptyPage:
        articles = paginator.page(paginator.num_pages)

    return render(
        request, 'reviews.html', {
            "articles": articles,
            "review_form": review_form,
            'appointment_form': appointment_form,
            'departments': department_set
        })
Beispiel #5
0
def services(request):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    departments = Department.objects.all()

    return render(request, 'services.html', locals())
Beispiel #6
0
def about(request):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    departments = Department.objects.all()
    article = About.objects.get(is_active=True)

    return render(request, 'about.html', locals())
Beispiel #7
0
def contacts(request):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    requisites = WordRequisites.objects.get(is_actual=True)
    departments = Department.objects.all()
    director = Employee.objects.filter(position="DR").get()
    main_doctor = Employee.objects.filter(position="MD").get()
    administration = Employee.objects.filter(position="AD").all()
    return render(request, 'contacts.html', locals())
Beispiel #8
0
 def test_max_appointment_booked(self):
     """ if MAX_APPOINTMENT_PER_SLOT has reached it will
         raise a validation error"""
     G(Appointment, time_slot='08:00', date_selected='2012-12-12')
     G(Appointment, time_slot='08:00', date_selected='2012-12-12')
     G(Appointment, time_slot='08:00', date_selected='2012-12-12')
     postdata = {
         'time_slot': u'08:00',
         'email': u'*****@*****.**',
         'date_selected': datetime.date(2012, 12, 12)
     }
     form = AppointmentForm(postdata)
     self.assertFalse(form.is_valid())
Beispiel #9
0
def text_page(request, news_id):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    departments = Department.objects.all()
    article = News.objects.get(id=news_id)
    artlist = list(News.objects.order_by('date'))
    ind = artlist.index(article)
    try:
        next_article = artlist.pop(ind + 1)
    except IndexError:
        next_article = News.objects.order_by('date').first()

    try:
        previous_article = artlist.pop(ind - 1)
    except IndexError:
        previous_article = News.objects.order_by('date').last()

    return render(request, 'text-page.html', locals())
Beispiel #10
0
def news(request):
    appointment_form = AppointmentForm(request.POST or None)
    if request.method == 'POST' and appointment_form.is_valid():
        appointment_form.save()
        return HttpResponseRedirect(request.META.get('HTTP_REFERER'))

    news_set = News.objects.all().order_by('-interest', 'date')
    department_set = Department.objects.all()

    paginator = Paginator(news_set, 6, orphans=3)
    page = request.GET.get('page')
    try:
        articles = paginator.page(page)
    except PageNotAnInteger:
        articles = paginator.page(1)
    except EmptyPage:
        articles = paginator.page(paginator.num_pages)

    return render(request, 'news.html', {
        "articles": articles,
        'departments': department_set
    })
Beispiel #11
0
def save_appointment(request):
    """
    """
    if request.method != 'POST':
        raise http.Http404

    appointment_form = AppointmentForm(request.POST)

    if appointment_form.is_valid():
        try:
            appointment = appointment_form.save(commit=False)
            form_dt = request.POST.get('datetime')
            # Tue Sep 15 2015 11:00:00 GMT+0000
            dt_obj = datetime.strptime(form_dt, "%a %b %d %Y %H:%M:%S GMT+0000")
            appointment.datetime = dt_obj
            appointment.save()

        except IntegrityError:
            return jsonSimpleAns(error='error')

    else:
        return jsonSimpleAns(error=appointment_form.errors)

    return render_to_response('success.html')
Beispiel #12
0
def CreateAppointmentView(request):

    form = AppointmentForm()
    context = {'form':form}

    if request.method == "POST":

        form = AppointmentForm(request.POST)

        if form.is_valid():

            appointment = form.save(commit=False)
            appointment.created_by = request.user
            appointment.save()

            return HttpResponseRedirect(reverse('appointment:list'))

        else:
            return HttpResponse(form.errors)

        
    return render(request,'appointment/create_appointment.html',context=context)