Пример #1
0
def register(request):
    mydb = mysql.connector.connect(host="us-cdbr-iron-east-01.cleardb.net", user="******", password='******',
                                   database='heroku_947e29c06a5b4a3')
    if request.user.is_authenticated:
        return render(request, 'base/profile.html')
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            air_crew = AirCrew()
            if air_crew.is_auth(form.cleaned_data['username']):
                user = User.objects.create_user(first_name =form.cleaned_data['first_name'], username = form.cleaned_data['username'],
                                                last_name = form.cleaned_data['last_name'], email=form.cleaned_data['Email'], password =form.cleaned_data['password'], )
                user.save()
                aircrew = AirCrew()
                aircrew.personal_num = form.cleaned_data['username']
                aircrew.movil = form.cleaned_data['movil']
                aircrew.category = form.cleaned_data['category']
                aircrew.status = form.cleaned_data['status']
                aircrew.InsertToDb()
                return redirect('/profile')
            else:
                return render(request, 'base/notauthorized.html')
    else:
        form = ContactForm()
    args = {'form': form}
    return render(request,'base/register.html', args)
Пример #2
0
def register(request):
    if request.user.is_authenticated:
        return render(request, 'base/profile.html')
    if request.method == "POST":
        form = ContactForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(
                first_name=form.cleaned_data['first_name'],
                username=form.cleaned_data['username'],
                last_name=form.cleaned_data['last_name'],
                password=form.cleaned_data['password'],
            )
            user.save()
            aircrew = AirCrew()
            aircrew.personal_num = form.cleaned_data['username']
            aircrew.movil = form.cleaned_data['movil']
            aircrew.category = form.cleaned_data['category']
            aircrew.status = form.cleaned_data['status']
            aircrew.InsertToDb()
            return redirect('/profile')
    else:
        form = ContactForm()
    args = {'form': form}
    return render(request, 'base/register.html', args)