mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Added Person creation
This commit is contained in:
@@ -30,7 +30,7 @@ class Person(models.Model):
|
||||
|
||||
address = models.TextField(blank=True, null=True)
|
||||
|
||||
comments = models.ManyToManyField('ModelComment')
|
||||
comments = models.ManyToManyField('ModelComment', blank=True)
|
||||
|
||||
def __unicode__(self):
|
||||
string = self.name
|
||||
|
||||
46
RIGS/templates/RIGS/person_form.html
Normal file
46
RIGS/templates/RIGS/person_form.html
Normal file
@@ -0,0 +1,46 @@
|
||||
{% extends request.is_ajax|yesno:'base_ajax.html,base.html' %}
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% block title %}Add Person{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-offset-1 col-sm-10">
|
||||
<h3>Add Person</h3>
|
||||
<div class="col-md-6">
|
||||
<form action="{{ form.action }}" method="post" class="form-horizontal">{% csrf_token %}
|
||||
{% include 'form_errors.html' %}
|
||||
<div class="form-group">
|
||||
<label for="{{ form.name.id_for_label }}" class="col-sm-2 control-label">{{ form.name.label }}</label>
|
||||
<div class="col-sm-10">
|
||||
{% render_field form.name class+="form-control" placeholder=form.name.label %}
|
||||
</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">
|
||||
<input class="btn btn-primary pull-right" type="submit" />
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
0
RIGS/templatetags/__init__.py
Normal file
0
RIGS/templatetags/__init__.py
Normal file
@@ -12,6 +12,7 @@ urlpatterns = patterns('',
|
||||
url('^user/login/$', 'RIGS.views.login', name='login'),
|
||||
|
||||
# People
|
||||
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonIndex.as_view()), name='person')
|
||||
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'),
|
||||
)
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django.shortcuts import render
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.views import generic
|
||||
import models
|
||||
|
||||
@@ -13,4 +13,8 @@ def login(request, **kwargs):
|
||||
return login(request)
|
||||
|
||||
class PersonIndex(generic.ListView):
|
||||
model = models.Person
|
||||
model = models.Person
|
||||
|
||||
class PersonCreate(generic.CreateView):
|
||||
model = models.Person
|
||||
success_url = reverse_lazy('person_list')
|
||||
Reference in New Issue
Block a user