mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 00:12:15 +00:00
And now the same for generic forms
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
{% extends 'base_assets.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}Edit Supplier{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<h1>Supplier
|
||||
{% if object %}
|
||||
Edit: {{ object.name }}
|
||||
{% else %}
|
||||
Create
|
||||
{% endif %}</h1>
|
||||
</div>
|
||||
<form method="POST">
|
||||
{% csrf_token %}
|
||||
{% include 'form_errors.html' %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.name.id_for_label }}" class="col-sm-2 control-label">Name</label>
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.name|add_class:'form-control' value=object.name %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.phone.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.phone.label }}</label>
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.phone class+="form-control" type="tel" placeholder=form.phone.label %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.email.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.email.label }}</label>
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.email class+="form-control" type="email" placeholder=form.email.label %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.address.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.address.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.address class+="form-control" placeholder=form.address.label %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="{{ form.notes.id_for_label }}"
|
||||
class="col-sm-2 control-label">{{ form.notes.label }}</label>
|
||||
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.notes class+="form-control" placeholder=form.notes.label %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-success">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -152,7 +152,7 @@ class SupplierList(BasePage):
|
||||
|
||||
|
||||
class SupplierForm(FormPage):
|
||||
_submit_locator = (By.CLASS_NAME, 'btn-success')
|
||||
_submit_locator = (By.CLASS_NAME, 'btn-primary')
|
||||
form_items = {
|
||||
'name': (regions.TextBox, (By.ID, 'id_name')),
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ from django.utils.decorators import method_decorator
|
||||
from django.views import generic
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
from versioning import versioning
|
||||
from PyRIGS.views import GenericListView, GenericDetailView
|
||||
from PyRIGS.views import GenericListView, GenericDetailView, GenericUpdateView, GenericCreateView, ModalURLMixin
|
||||
|
||||
|
||||
@method_decorator(csrf_exempt, name='dispatch')
|
||||
@@ -249,16 +249,20 @@ class SupplierDetail(GenericDetailView):
|
||||
return context
|
||||
|
||||
|
||||
class SupplierCreate(generic.CreateView):
|
||||
class SupplierCreate(GenericCreateView, ModalURLMixin):
|
||||
model = models.Supplier
|
||||
form_class = forms.SupplierForm
|
||||
template_name = 'supplier_update.html'
|
||||
|
||||
def get_success_url(self):
|
||||
return self.get_close_url('supplier_update', 'supplier_detail')
|
||||
|
||||
|
||||
class SupplierUpdate(generic.UpdateView):
|
||||
class SupplierUpdate(GenericUpdateView, ModalURLMixin):
|
||||
model = models.Supplier
|
||||
form_class = forms.SupplierForm
|
||||
template_name = 'supplier_update.html'
|
||||
|
||||
def get_success_url(self):
|
||||
return self.get_close_url('supplier_update', 'supplier_detail')
|
||||
|
||||
|
||||
class CableTypeList(generic.ListView):
|
||||
|
||||
Reference in New Issue
Block a user