def forms_items(request, form_uuid=None): items = FormData.objects.filter(is_active=True) form_item = None if form_uuid: try: form_item = items.get(form_uuid=form_uuid) except FormData.DoesNotExist: messages.error(request, "The form selected to be edited no longer exists.") return redirect("employees:forms_items") if request.method == "POST": form = FormDataForm(request.POST, request.FILES, instance=form_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() form.save_m2m() collect_static() # document # formitem_update messages.success(request, "The form was saved successfully.") return redirect("employees:forms_items") else: messages.error(request, settings.GENERIC_ERROR) else: form = FormDataForm(instance=form_item) return render(request, "manage_forms.html", {"form": form, "form_items": items, "form_uuid": form_uuid})
def featured_images(request, image_uuid=None): items = ImageItem.objects.all() image_item = None if image_uuid: try: image_item = items.get(image_uuid=image_uuid) except ImageItem.DoesNotExist: messages.error(request, "The featured image selected to be edited no longer exists.") return redirect("employees:featured_images") if request.method == "POST": form = ImageItemForm(request.POST, request.FILES, instance=image_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() collect_static() # image # imageitem_udpate messages.success(request, "The featured image was saved successfully.") return redirect("employees:featured_images") else: messages.error(request, settings.GENERIC_ERROR) else: form = ImageItemForm(instance=image_item) return render( request, "featured_images.html", {"form": form, "featured_image_items": items, "image_uuid": image_uuid} )
def forms_items(request, form_uuid=None): items = FormData.objects.filter(is_active=True) form_item = None if form_uuid: try: form_item = items.get(form_uuid=form_uuid) except FormData.DoesNotExist: messages.error(request, 'The form selected to be edited no longer exists.') return redirect('employees:forms_items') if request.method == 'POST': form = FormDataForm(request.POST, request.FILES, instance=form_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() form.save_m2m() collect_static() # document # formitem_update with sys.wr messages.success(request, 'The form was saved successfully.') return redirect('employees:forms_items')
def featured_images(request, image_uuid=None): items = ImageItem.objects.all() image_item = None if image_uuid: try: image_item = items.get(image_uuid=image_uuid) except ImageItem.DoesNotExist: messages.error(request, 'The featured image selected to be edited no longer exists.') return redirect('employees:featured_images') if request.method == 'POST': form = ImageItemForm(request.POST, request.FILES, instance=image_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() collect_static() # image # imageitem_udpate messages.success(request, 'The featured image was saved successfully.') return redirect('employees:featured_images') else: messages.error(request, settings.GENERIC_ERROR) else: form = ImageItemForm(instance=image_item) return render(request, 'featured_images.html', {'form': form, 'featured_image_items': items, 'image_uuid': image_uuid})
def update_static_resources(request): try: collect_static() messages.success(request, 'The Collect Static script ran successfully') except Exception as e: messages.error(request, 'Something happened: {}'.format(e)) return render(request, 'collect_static.html')
def task_orders(request, task_uuid=None): items = TaskOrder.objects.all() task_order_item = None if task_uuid: try: task_order_item = items.get(task_uuid=task_uuid) except TaskOrder.DoesNotExist: messages.error(request, "The task order selected to be edited no longer exists.") return redirect("employees:task_orders") if request.method == "POST": form = TaskOrderForm(request.POST, request.FILES, instance=task_order_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() collect_static() # document # taskorder_update if settings.IS_PROD: # copy the document to the public site shutil.copy(item.document.url, "{}/{}".format(settings.DOCUMENT_PATH, item.get_document_name)) http.request("GET", settings.PUBLIC_URL) messages.success(request, "The task order was saved successfully.") return redirect("employees:task_orders") else: messages.error(request, settings.GENERIC_ERROR) else: form = TaskOrderForm(instance=task_order_item) return render(request, "task_orders.html", {"form": form, "task_order_items": items, "task_uuid": task_uuid})
def task_orders(request, task_uuid=None): items = TaskOrder.objects.all() task_order_item = None if task_uuid: try: task_order_item = items.get(task_uuid=task_uuid) except TaskOrder.DoesNotExist: messages.error(request, 'The task order selected to be edited no longer exists.') return redirect('employees:task_orders') if request.method == 'POST': form = TaskOrderForm(request.POST, request.FILES, instance=task_order_item) if form.is_valid(): item = form.save(commit=False) item.updated_by = request.user item.save() collect_static() # document # taskorder_update if settings.IS_PROD: # copy the document to the public site shutil.copy(item.document.url, '{}/{}'.format(settings.DOCUMENT_PATH, item.get_document_name)) http.request('GET', settings.PUBLIC_URL) messages.success(request, 'The task order was saved successfully.') return redirect('employees:task_orders') else: messages.error(request, settings.GENERIC_ERROR) else: form = TaskOrderForm(instance=task_order_item) return render(request, 'task_orders.html', {'form': form, 'task_order_items': items, 'task_uuid': task_uuid})