mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-22 16:02:16 +00:00
Person CRUD working
This commit is contained in:
@@ -34,6 +34,6 @@ class Person(models.Model):
|
|||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
string = self.name
|
string = self.name
|
||||||
if self.comments:
|
if self.comments.count() > 0:
|
||||||
string += "*"
|
string += "*"
|
||||||
return string
|
return string
|
||||||
30
RIGS/templates/RIGS/person_detail.html
Normal file
30
RIGS/templates/RIGS/person_detail.html
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
{% extends request.is_ajax|yesno:"base_ajax.html,base.html" %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
{% block title %}{{ object.name }}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="col-sm-10 col-sm-offset-1">
|
||||||
|
<h3>{{ object.name }}</h3>
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="{% url 'person_update' object.pk %}" class="btn btn-primary">Edit <span class="glyphicon glyphicon-pencil"></span></a>
|
||||||
|
</div>
|
||||||
|
<div class="row col-sm-12">
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<dl class="dl-horizontal">
|
||||||
|
<dt>Name</dt>
|
||||||
|
<dd>{{ object.name }}</dd>
|
||||||
|
|
||||||
|
<dt>Phone</dt>
|
||||||
|
<dd><a href="tel:{{ object.phone }}">{{ object.phone }}</a></dd>
|
||||||
|
|
||||||
|
<dt>Email</dt>
|
||||||
|
<dd><a href="mailto:{{ object.email }}">{{ object.email }}</a></dd>
|
||||||
|
|
||||||
|
<dt>Address</dt>
|
||||||
|
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||||
|
</dl>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
{% extends request.is_ajax|yesno:'base_ajax.html,base.html' %}
|
{% extends request.is_ajax|yesno:'base_ajax.html,base.html' %}
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block title %}Add Person{% endblock %}
|
{% block title %}{% if object.pk %}Edit {{ object.name }}{% else %}Add Person{% endif %}{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-sm-offset-1 col-sm-10">
|
<div class="col-sm-offset-1 col-sm-10">
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ urlpatterns = patterns('',
|
|||||||
|
|
||||||
# People
|
# People
|
||||||
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonIndex.as_view()), name='person_list'),
|
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonIndex.as_view()), name='person_list'),
|
||||||
url(r'^people/add$', permission_required_with_403('RIGS.add_person')(views.PersonCreate.as_view()), name='person_add'),
|
url(r'^people/(?P<pk>\d+)/$', permission_required_with_403('RIGS.view_person')(views.PersonDetail.as_view()),
|
||||||
|
name='person_detail'),
|
||||||
|
url(r'^people/add/$', permission_required_with_403('RIGS.add_person')(views.PersonCreate.as_view()), name='person_add'),
|
||||||
|
url(r'^people/(?P<pk>\d+)/edit/$', permission_required_with_403('RIGS.change_person')(views.PersonUpdate.as_view()), name='person_update'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,21 @@ def login(request, **kwargs):
|
|||||||
class PersonIndex(generic.ListView):
|
class PersonIndex(generic.ListView):
|
||||||
model = models.Person
|
model = models.Person
|
||||||
|
|
||||||
|
class PersonDetail(generic.DetailView):
|
||||||
|
model = models.Person
|
||||||
|
|
||||||
class PersonCreate(generic.CreateView):
|
class PersonCreate(generic.CreateView):
|
||||||
model = models.Person
|
model = models.Person
|
||||||
success_url = reverse_lazy('person_list')
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('person_detail', kwargs={
|
||||||
|
'pk': self.object.pk,
|
||||||
|
})
|
||||||
|
|
||||||
|
class PersonUpdate(generic.UpdateView):
|
||||||
|
model = models.Person
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
return reverse_lazy('person_detail', kwargs={
|
||||||
|
'pk': self.object.pk,
|
||||||
|
})
|
||||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
Reference in New Issue
Block a user