def Status(request): try: if CheckAccess(request,'23') != 'OK': return render_to_response("mtmc/notaccess/mtmc.html") except: return HttpResponseRedirect('/') try: eq_id = request.session['eq_id'] except: return HttpResponseRedirect('/mtmc') if request.method == 'POST': form = StatusForm(request.POST) if form.is_valid(): status = form.cleaned_data['status'] comment = form.cleaned_data['comment'] AddStatus(eq_id,status,comment,request) eq = GetEq(eq_id) form = StatusForm(None) data = GetStatusList(eq_id) c = RequestContext(request,{'form':form,'eq':eq,'data':data,'tmc':TmcUrl(eq)}) c.update(csrf(request)) return render_to_response("mtmc/status.html",c)
def change_status(request, task_id): status_form = StatusForm(request.POST) if status_form.is_valid(): Task.objects.filter( pk=task_id).update( status=status_form.cleaned_data['status']) return redirect('/tasks/get/%s/' % task_id)
def add (request): form = StatusForm(request.POST or None) if request.method == 'POST' and form.is_valid(): form.save() return HttpResponseRedirect('/status') context = RequestContext(request, {'form': form}) return render_to_response('status/status_form.html', context)
def update(request, id): status = Status.objects.get(pk=id) if request.method == 'POST': form = StatusForm(request.POST, instance=status) if form.is_valid(): form.save() return HttpResponseRedirect('/status') else: form = StatusForm(instance=status) context = RequestContext(request, {'form': form, 'id': id}) return render_to_response('status/status_edit.html', context)
def status(request): if request.POST: form = StatusForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/status/') else: form = StatusForm() types = Status.objects.all() title = "Status Types" url = "status" return render(request, 'add.html', locals())
def addStatus(request): if request.method == 'POST': # formulario enviado statusform = StatusForm(request.POST) if statusform.is_valid(): # formulario validado correctamente statusform.save() return HttpResponseRedirect('/categorias/') else: # formulario inicial formset = StatusForm() return render_to_response('puntoventa/addProducto.html', { 'formset': StatusForm }, context_instance=RequestContext(request))
def Page4(request): if CheckAccess(request,'5') != 'OK': return render_to_response("notaccess.html") try: contract_id = request.session['contract_id'] except: return HttpResponseRedirect('/contract') ### --- Проверка доступа именно к этой заявке --- if CheckAccess(request,'4') != 'OK' and CheckDAccess(GetUserKod(request),contract_id) != 'OK': return HttpResponseRedirect('/contract') if request.method == 'POST': form = StatusForm(request.POST) if form.is_valid(): comment = form.cleaned_data['comment'] status = form.cleaned_data['status'] r = NewDStatus(request,GetUserKod(request),contract_id,comment,status) if r == 'OK': ### --- Уведомление о статусе --- EmailStatusInfo(contract_id) ### --- Уведомление согласующими --- if status == '2' or status == '3': EmailToPerson(contract_id) ### --- Получение данных заявки --- data = GetDData(contract_id) ### --- Доступные статусы --- status_list = GetDStatusList(data[5]) form = StatusForm() form.fields['status'].choices = status_list ### --- Получение истории статусов --- d = GetDStatus(contract_id) c = RequestContext(request,{'data':data,'form':form,'d':d}) c.update(csrf(request)) return render_to_response("contract/page4.html",c)
def update_status(request): user = check_validation(request) data = 'Kids Zone is Cool' if user: if request.method == "POST": form = StatusForm(request.POST) if form.is_valid(): status = form.cleaned_data.get('status') user_name = user.username print user_name USER = User.objects.all().filter(username=user_name).first() USER.status = status # status_text=User(username=user_name,status=status) # status_text.save() # data=status print status + "is posted" return render(request, 'feed.html', {}) else: return redirect('/login/')
def editstatus(request, status_id): types = get_object_or_404(Status, pk=status_id) t = "Edit" if request.POST: form = StatusForm(request.POST, instance=types) if form.is_valid(): form.save() return HttpResponseRedirect('/status/') else: form = StatusForm(instance=types) types = Status.objects.all() title = "Edit Status Type" url = "status" return render_to_response("edit.html", { 'form': form, 't': t, }, context_instance=RequestContext(request, locals()))
def TmcData3(request): """ if CheckAccess(request,'2') != 'OK': return render_to_response("tmc/notaccess/tmc.html") """ ## --- Номер заявки --- try: tmc_id = request.GET['tmc_id'] request.session['tmc_id'] = tmc_id except: pass try: tmc_id = request.session['tmc_id'] except: return HttpResponseRedirect("/tmc") if request.method == 'POST': form = StatusForm(request.POST) if form.is_valid(): comment = form.cleaned_data['comment'] status = form.cleaned_data['status'] r = NewTmcStatus(GetUserKod(request), tmc_id, comment, status) if r == 'OK': EmailStatusInfo(tmc_id) d = GetTmcData(tmc_id) data = GetStatusHistory(tmc_id) form = StatusForm(None) form.fields['status'].choices = GetStatusList(d[5]) s = GetLastStatus(tmc_id) c = RequestContext(request, {'d': d, 'form': form, 'data': data, 's': s}) c.update(csrf(request)) return render_to_response("tmc/tmcdata3.html", c)
def MyStatus(request): ### --- Получение кода учетной записи --- try: kod = GetUserKod(request) except: return render_to_response("notaccess.html") if request.method == 'POST': form = StatusForm(request.POST) if form.is_valid(): status = form.cleaned_data['status'] NewStatus(kod,status) ## --- Данные учетной записи --- r = GetRec(kod) form = StatusForm(None) c = RequestContext(request,{'form':form,'r':r}) c.update(csrf(request)) return render_to_response("mydata/status.html",c)
def add_edit_item(request, model_name, add_edit, edit_id): """Add/Edit page for the inventory""" if add_edit == "add": edit_id = None if _checkModel(model_name): directory = "asset_inventory/add_edit_Pages/" # Adding or Editing a Job if model_name == "Job": templateFile = directory + "Job.html" post_data = request.POST or None try: Job_Instance = Job.objects.get(pk=edit_id) except Job.DoesNotExist: Job_Instance = None if add_edit == "edit": return HttpResponseRedirect(reverse("asset_inventory_add_edit_item", args=["Job", "add", "new"])) Job_Form = JobForm(post_data, instance=Job_Instance) if Job_Form.is_valid(): Job_Occurance = Job_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Job"])) return render_to_response(templateFile, {"form": Job_Form}, context_instance=RequestContext(request)) # Adding or Editing a Location elif model_name == "Location": templateFile = directory + "Location.html" post_data = request.POST or None try: Location_Instance = Location.objects.get(pk=edit_id) except Location.DoesNotExist: Location_Instance = None if add_edit == "edit": return HttpResponseRedirect( reverse("asset_inventory_add_edit_item", args=["Location", "add", "new"]) ) Location_Form = LocationForm(post_data, instance=Location_Instance) if Location_Form.is_valid(): Location_Occurance = Location_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Location"])) return render_to_response(templateFile, {"form": Location_Form}, context_instance=RequestContext(request)) # Adding or Editing a Person elif model_name == "Person": templateFile = directory + "Person.html" post_data = request.POST or None try: Person_Instance = Person.objects.get(pk=edit_id) except Person.DoesNotExist: Person_Instance = None if add_edit == "edit": return HttpResponseRedirect(reverse("asset_inventory_add_edit_item", args=["Person", "add", "new"])) Person_Form = PersonForm(post_data, instance=Person_Instance) if Person_Form.is_valid(): Person_Occurance = Person_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Person"])) return render_to_response(templateFile, {"form": Person_Form}, context_instance=RequestContext(request)) # Adding or Editing a Purchase elif model_name == "Purchase": templateFile = directory + "Purchase.html" post_data = request.POST or None try: Purchase_Instance = Purchase.objects.get(pk=edit_id) except Purchase.DoesNotExist: Purchase_Instance = None if add_edit == "edit": return HttpResponseRedirect( reverse("asset_inventory_add_edit_item", args=["Purchase", "add", "new"]) ) Purchase_Form = PurchaseForm(post_data, instance=Purchase_Instance) if Purchase_Form.is_valid(): Purchase_Occurance = Purchase_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Purchase"])) return render_to_response(templateFile, {"form": Purchase_Form}, context_instance=RequestContext(request)) # Adding or Editing a Status elif model_name == "Status": templateFile = directory + "Status.html" post_data = request.POST or None try: Status_Instance = Status.objects.get(pk=edit_id) except Status.DoesNotExist: Status_Instance = None if add_edit == "edit": return HttpResponseRedirect(reverse("asset_inventory_add_edit_item", args=["Status", "add", "new"])) Status_Form = StatusForm(post_data, instance=Status_Instance) if Status_Form.is_valid(): Status_Occurance = Status_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Status"])) return render_to_response(templateFile, {"form": Status_Form}, context_instance=RequestContext(request)) # Adding or Editing a Esign elif model_name == "Esign": templateFile = directory + "Esign.html" post_data = request.POST or None try: Esign_Instance = Esign.objects.get(pk=edit_id) except Esign.DoesNotExist: Esign_Instance = None if add_edit == "edit": return HttpResponseRedirect(reverse("asset_inventory_add_edit_item", args=["Esign", "add", "new"])) Esign_Form = EsignForm(post_data, instance=Esign_Instance) if Esign_Form.is_valid(): Esign_Occurance = Esign_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Esign"])) return render_to_response(templateFile, {"form": Esign_Form}, context_instance=RequestContext(request)) # Adding or Editing a Device elif model_name == "Device": templateFile = directory + "Device.html" post_data = request.POST or None try: Device_Instance = Device.objects.get(pk=edit_id) except Device.DoesNotExist: Device_Instance = None if add_edit == "edit": return HttpResponseRedirect(reverse("asset_inventory_add_edit_item", args=["Device", "add", "new"])) Device_Form = DeviceForm(post_data, instance=Device_Instance) if Device_Form.is_valid(): Device_Occurance = Device_Form.save() return HttpResponseRedirect(reverse("asset_inventory_list_model", args=["Device"])) return render_to_response(templateFile, {"form": Device_Form}, context_instance=RequestContext(request)) # This is a catch all response, if some unforseen error manages # to occur with the calling of add/edit pages else: render_to_response(reverse("homepage"))