Пример #1
0
def add_user(request):
    c = {}
    if request.method == 'POST':
        ucform = UserCreateForm(request.POST)
        upform = UserProfileForm(request.POST)
        docform = DoctorForm(request.POST)
        invoiceform = MiniInvoiceForm(request.POST)
        if ucform.is_valid() and upform.is_valid() and docform.is_valid() and invoiceform.is_valid():
            i = invoiceform.save()
            u = ucform.save()
            up = upform.save()
            doc = docform.save()
            doc.refer_userprofile = up
            for st in settings.SLOT_TYPE:
                doc.get_colorslot(st[0])
            doc.invoices.add(i)
            doc.save()
            up.user = u
            up.doctors.add(doc)
            up.current_doctor = doc
            up.save()
            doc.set_slug()
            doc.save()
            mail_user_welcome(request, up, False)
            return HttpResponseRedirect('/')
        else:
            c['form'] = [ucform, upform, docform, invoiceform]
            messages.error(request, "Error")
    else:
        c['form'] = [UserCreateForm(), UserProfileForm(), DoctorForm(), MiniInvoiceForm()]
    c['url'] = "/user/add_user/"
    c['title'] = _("New doctor")
    return render(request, 'form.tpl', c)
Пример #2
0
def create_user(request):
    c = {}
    if request.method == 'POST':
        ucform = UserCreateForm(request.POST)
        upform = UserProfileForm(request.POST)
        docform = DoctorForm(request.POST)
        invoiceform = MiniInvoiceForm(request.POST)
        if ucform.is_valid() and upform.is_valid() and docform.is_valid(
        ) and invoiceform.is_valid():
            i = invoiceform.save()
            u = ucform.save()
            up = upform.save()
            u.is_active = False
            u.save()
            i.active = True
            i.save()
            up.confirm = string_random(32)
            doc = docform.save()
            doc.refer_userprofile = up
            for st in settings.SLOT_TYPE:
                doc.get_colorslot(st[0])
            doc.invoices.add(i)
            doc.save()
            up.user = u
            up.doctors.add(doc)
            # TODO regarder dans collaborator pour voir si il faut en rajouter
            up.current_doctor = doc
            up.save()
            doc.set_slug()
            doc.save()
            mail_user_welcome(request, up, True)
            c['mail'] = True
            return render(request, 'valid.tpl', c)
        else:
            c['form'] = [ucform, upform, docform, invoiceform]
            messages.error(request, "Error")
    else:
        c['form'] = [
            UserCreateForm(),
            UserProfileForm(),
            DoctorForm(),
            MiniInvoiceForm()
        ]
    c['url'] = "/user/create_user/"
    c['title'] = _("New doctor")
    return render(request, 'form.tpl', c)
Пример #3
0
def create_user(request):
    c = {}
    if request.method == 'POST':
        ucform = UserCreateForm(request.POST)
        upform = UserProfileForm(request.POST)
        docform = DoctorForm(request.POST)
        invoiceform = MiniInvoiceForm(request.POST)
        if ucform.is_valid() and upform.is_valid() and docform.is_valid() and invoiceform.is_valid():
            i = invoiceform.save()
            u = ucform.save()
            up = upform.save()
            u.is_active = False
            u.save()
            i.active = True
            i.save()
            up.confirm = string_random(32)
            doc = docform.save()
            doc.refer_userprofile = up
            for st in settings.SLOT_TYPE:
                doc.get_colorslot(st[0])
            doc.invoices.add(i)
            doc.save()
            up.user = u
            up.doctors.add(doc)
            # TODO regarder dans collaborator pour voir si il faut en rajouter
            up.current_doctor = doc
            up.save()
            doc.set_slug()
            doc.save()
            mail_user_welcome(request, up, True)
            c['mail'] = True
            return render(request, 'valid.tpl', c)
        else:
            c['form'] = [ucform, upform, docform, invoiceform]
            messages.error(request, "Error")
    else:
        c['form'] = [UserCreateForm(), UserProfileForm(), DoctorForm(), MiniInvoiceForm()]
    c['url'] = "/user/create_user/"
    c['title'] = _("New doctor")
    return render(request, 'form.tpl', c)
Пример #4
0
def add_user(request):
    c = {}
    if request.method == 'POST':
        ucform = UserCreateForm(request.POST)
        upform = UserProfileForm(request.POST)
        docform = DoctorForm(request.POST)
        invoiceform = MiniInvoiceForm(request.POST)
        if ucform.is_valid() and upform.is_valid() and docform.is_valid(
        ) and invoiceform.is_valid():
            i = invoiceform.save()
            u = ucform.save()
            up = upform.save()
            doc = docform.save()
            doc.refer_userprofile = up
            for st in settings.SLOT_TYPE:
                doc.get_colorslot(st[0])
            doc.invoices.add(i)
            doc.save()
            up.user = u
            up.doctors.add(doc)
            up.current_doctor = doc
            up.save()
            doc.set_slug()
            doc.save()
            mail_user_welcome(request, up, False)
            return HttpResponseRedirect('/')
        else:
            c['form'] = [ucform, upform, docform, invoiceform]
            messages.error(request, "Error")
    else:
        c['form'] = [
            UserCreateForm(),
            UserProfileForm(),
            DoctorForm(),
            MiniInvoiceForm()
        ]
    c['url'] = "/user/add_user/"
    c['title'] = _("New doctor")
    return render(request, 'form.tpl', c)