mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Updates to person model. Removed comments for now in favour of a simple notes section that can be easily modified as a text field. Will look at introducing this again in the future.
This commit is contained in:
41
RIGS/migrations/0002_modelcomment_person.py
Normal file
41
RIGS/migrations/0002_modelcomment_person.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ModelComment',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('postedAt', models.DateTimeField(auto_now=True)),
|
||||
('message', models.TextField()),
|
||||
('user', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Person',
|
||||
fields=[
|
||||
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
|
||||
('name', models.CharField(max_length=50)),
|
||||
('phone', models.CharField(max_length=15, null=True, blank=True)),
|
||||
('email', models.EmailField(max_length=75, null=True, blank=True)),
|
||||
('address', models.TextField(null=True, blank=True)),
|
||||
('comments', models.ManyToManyField(to='RIGS.ModelComment')),
|
||||
],
|
||||
options={
|
||||
},
|
||||
bases=(models.Model,),
|
||||
),
|
||||
]
|
||||
31
RIGS/migrations/0003_auto_20141031_0219.py
Normal file
31
RIGS/migrations/0003_auto_20141031_0219.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('RIGS', '0002_modelcomment_person'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveField(
|
||||
model_name='modelcomment',
|
||||
name='user',
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name='person',
|
||||
name='comments',
|
||||
),
|
||||
migrations.DeleteModel(
|
||||
name='ModelComment',
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='person',
|
||||
name='notes',
|
||||
field=models.TextField(null=True, blank=True),
|
||||
preserve_default=True,
|
||||
),
|
||||
]
|
||||
@@ -16,12 +16,6 @@ class Profile(AbstractUser):
|
||||
url = "https://www.gravatar.com/avatar/" + hashlib.md5(self.email).hexdigest() + "?d=identicon&s=500"
|
||||
return url
|
||||
|
||||
class ModelComment(models.Model):
|
||||
user = models.ForeignKey(settings.AUTH_USER_MODEL)
|
||||
postedAt = models.DateTimeField(auto_now=True)
|
||||
|
||||
message = models.TextField()
|
||||
|
||||
@reversion.register
|
||||
class Person(models.Model):
|
||||
name = models.CharField(max_length=50)
|
||||
@@ -30,10 +24,10 @@ class Person(models.Model):
|
||||
|
||||
address = models.TextField(blank=True, null=True)
|
||||
|
||||
comments = models.ManyToManyField('ModelComment', blank=True)
|
||||
notes = models.TextField(blank=True, null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
string = self.name
|
||||
if self.comments.count() > 0:
|
||||
if len(self.notes) > 0:
|
||||
string += "*"
|
||||
return string
|
||||
@@ -6,8 +6,10 @@
|
||||
{% 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>
|
||||
<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">
|
||||
@@ -23,6 +25,9 @@
|
||||
|
||||
<dt>Address</dt>
|
||||
<dd>{{ object.address|linebreaksbr }}</dd>
|
||||
|
||||
<dt>Notes</dt>
|
||||
<dd>{{ object.notes|linebreaksbr }}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -37,6 +37,13 @@
|
||||
</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">
|
||||
<input class="btn btn-primary pull-right" type="submit" />
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<td>Name</td>
|
||||
<td>Email</td>
|
||||
<td>Phone</td>
|
||||
<td>Comments</td>
|
||||
<td>Notes</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -27,7 +27,7 @@
|
||||
<td>{{ person.name }}</td>
|
||||
<td>{{ person.email }}</td>
|
||||
<td>{{ person.phone }}</td>
|
||||
<td>{{ person.comment_list|length }}</td>
|
||||
<td>{{ person.notes|yesno|capfirst }}</td>
|
||||
<td>Add buttons</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
|
||||
27
RIGS/urls.py
27
RIGS/urls.py
@@ -5,17 +5,24 @@ from RIGS import views
|
||||
from PyRIGS.decorators import permission_required_with_403
|
||||
|
||||
urlpatterns = patterns('',
|
||||
# Examples:
|
||||
# url(r'^$', 'PyRIGS.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
# Examples:
|
||||
# url(r'^$', 'PyRIGS.views.home', name='home'),
|
||||
# url(r'^blog/', include('blog.urls')),
|
||||
url(r'^closemodal/$', views.CloseModal.as_view(), name='closemodal'),
|
||||
|
||||
url('^user/login/$', 'RIGS.views.login', name='login'),
|
||||
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_list'),
|
||||
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'),
|
||||
# People
|
||||
url(r'^people/$', permission_required_with_403('RIGS.view_person')(views.PersonIndex.as_view()),
|
||||
name='person_list'),
|
||||
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'),
|
||||
)
|
||||
|
||||
|
||||
@@ -12,6 +12,18 @@ def login(request, **kwargs):
|
||||
from django.contrib.auth.views import login
|
||||
return login(request)
|
||||
|
||||
"""
|
||||
Called from a modal window (e.g. when an item is submitted to an event/invoice).
|
||||
May optionally also include some javascript in a success message to cause a load of
|
||||
the new information onto the page.
|
||||
"""
|
||||
class CloseModal(generic.TemplateView):
|
||||
template_name = 'closemodal.html'
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
from django.contrib import messages
|
||||
return {'messages', messages.get_messages(self.request)}
|
||||
|
||||
class PersonIndex(generic.ListView):
|
||||
model = models.Person
|
||||
|
||||
|
||||
BIN
db.sqlite3
BIN
db.sqlite3
Binary file not shown.
@@ -116,6 +116,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="modal"></div>
|
||||
|
||||
<script src="//code.jquery.com/jquery-latest.min.js"></script>
|
||||
<script>
|
||||
Date.prototype.getISOString = function() {
|
||||
@@ -133,6 +135,7 @@
|
||||
$('.navbar-collapse').addClass('collapse')
|
||||
</script>
|
||||
<script src="{% static "js/dropdown.js" %}"></script>
|
||||
<script src="{% static "js/modal.js" %}"></script>
|
||||
{% block js %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user