def authinfo_add_mini(request): status = 0 authinfo_id = 0 if request.method == 'POST': form =AuthInfoForm(request.POST) if form.is_valid(): form.save() auth_name = request.POST.get('dis_name', '') auth_info = AuthInfo.objects.get(dis_name=auth_name) authinfo_id = auth_info.id status = 1 else: status = 2 else: form = AuthInfoForm() results = { 'form': form, 'request': request, 'status': status, 'auth_id': authinfo_id, 'auth_name': request.POST.get('dis_name', ''), 'page_type': "mini" } return render(request, 'appconf/authinfo_add_edit_mini.html', results)
def authinfo_add(request): temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = AuthInfoForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('authinfo_list')) else: form = AuthInfoForm() results = { 'form': form, 'request': request, 'temp_name': temp_name, 'page_type': "whole" } return render(request, 'appconf/authinfo_add_edit.html', results)
def authinfo_add_mini(request): status = 0 authinfo_id = 0 if request.method == 'POST': form = AuthInfoForm(request.POST) if form.is_valid(): form.save() auth_name = request.POST.get('username', '') auth_info = AuthInfo.objects.get(username=auth_name) authinfo_id = auth_info.id status = 1 else: status = 2 else: form = AuthInfoForm() results = { 'form': form, 'request': request, 'status': status, 'auth_id': authinfo_id, 'auth_name': request.POST.get('username', ''), 'page_type': "mini" } return render(request, 'appconf/authinfo_add_edit_mini.html', results)
def authinfo_edit(request, authinfo_id, mini=False): authinfo = AuthInfo.objects.get(id=authinfo_id) temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = AuthInfoForm(request.POST, instance=authinfo) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('authinfo_list')) else: form = AuthInfoForm(instance=authinfo) results = { 'form': form, 'authinfo_id': authinfo_id, 'request': request, 'temp_name': temp_name, 'page_type': "whole" } return render(request, 'appconf/authinfo_add_edit.html', results)