From fefe3538236df9586cddf4f58e1f262151204a89 Mon Sep 17 00:00:00 2001 From: tomtom5152 Date: Fri, 31 Oct 2014 02:23:20 +0000 Subject: [PATCH] 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. --- RIGS/migrations/0002_modelcomment_person.py | 41 ++++++++++++++++++++ RIGS/migrations/0003_auto_20141031_0219.py | 31 +++++++++++++++ RIGS/models.py | 10 +---- RIGS/templates/RIGS/person_detail.html | 7 +++- RIGS/templates/RIGS/person_form.html | 7 ++++ RIGS/templates/RIGS/person_list.html | 4 +- RIGS/urls.py | 27 ++++++++----- RIGS/views.py | 12 ++++++ db.sqlite3 | Bin 60416 -> 62464 bytes templates/base.html | 3 ++ 10 files changed, 121 insertions(+), 21 deletions(-) create mode 100644 RIGS/migrations/0002_modelcomment_person.py create mode 100644 RIGS/migrations/0003_auto_20141031_0219.py diff --git a/RIGS/migrations/0002_modelcomment_person.py b/RIGS/migrations/0002_modelcomment_person.py new file mode 100644 index 00000000..346d46f0 --- /dev/null +++ b/RIGS/migrations/0002_modelcomment_person.py @@ -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,), + ), + ] diff --git a/RIGS/migrations/0003_auto_20141031_0219.py b/RIGS/migrations/0003_auto_20141031_0219.py new file mode 100644 index 00000000..3bb2f635 --- /dev/null +++ b/RIGS/migrations/0003_auto_20141031_0219.py @@ -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, + ), + ] diff --git a/RIGS/models.py b/RIGS/models.py index 705b6ba5..3a08fcf1 100644 --- a/RIGS/models.py +++ b/RIGS/models.py @@ -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 \ No newline at end of file diff --git a/RIGS/templates/RIGS/person_detail.html b/RIGS/templates/RIGS/person_detail.html index 5548b60b..a126e198 100644 --- a/RIGS/templates/RIGS/person_detail.html +++ b/RIGS/templates/RIGS/person_detail.html @@ -6,8 +6,10 @@ {% block content %}

{{ object.name }}

+
@@ -23,6 +25,9 @@
Address
{{ object.address|linebreaksbr }}
+ +
Notes
+
{{ object.notes|linebreaksbr }}
diff --git a/RIGS/templates/RIGS/person_form.html b/RIGS/templates/RIGS/person_form.html index 7266e013..f1161571 100644 --- a/RIGS/templates/RIGS/person_form.html +++ b/RIGS/templates/RIGS/person_form.html @@ -37,6 +37,13 @@
+
+ +
+ {% render_field form.notes class+="form-control" placeholder=form.notes.label %} +
+
+
diff --git a/RIGS/templates/RIGS/person_list.html b/RIGS/templates/RIGS/person_list.html index d76117d8..46093097 100644 --- a/RIGS/templates/RIGS/person_list.html +++ b/RIGS/templates/RIGS/person_list.html @@ -16,7 +16,7 @@ Name Email Phone - Comments + Notes @@ -27,7 +27,7 @@ {{ person.name }} {{ person.email }} {{ person.phone }} - {{ person.comment_list|length }} + {{ person.notes|yesno|capfirst }} Add buttons {% empty %} diff --git a/RIGS/urls.py b/RIGS/urls.py index a5a933f7..4cc829e4 100644 --- a/RIGS/urls.py +++ b/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\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\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\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\d+)/edit/$', + permission_required_with_403('RIGS.change_person')(views.PersonUpdate.as_view()), + name='person_update'), ) diff --git a/RIGS/views.py b/RIGS/views.py index 718a07f1..a8a43daa 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -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 diff --git a/db.sqlite3 b/db.sqlite3 index 9a039e378bb4b1ea96dee40cceedb9b6176b21d5..e437d91f8b0ce687c9bd6b069e64c17cd8ee9863 100644 GIT binary patch delta 1345 zcmaKs4MFc4%b?V_Ko3>^#$f1-JL!@4S1- zIrsd}yXR)`76$L({k+U3#+ZSZun^Uwm7cODR&_Tug=T4(C(BekzzY7rulNZIn8z*L zIMyExcJ<0{UD=5mAobRcl5ebe6+hVEw`|c59J!?C}bRkz-!d7;l6c4 z8N8Y;gI}NBT&cK{Ur>pL4o8*U9j&eMqbnma@5%`|@bP;jeZ`QzLLz>K+Ylkvv>O^6 ze30=$ex6_Ft3naG#hc=kxGENqPK^=9D89sP+O~aM{*Wk=pC-!XapILksdOi*rHQyZ zoiD$cE|O=7$aIB#W?GY(#L|>YCZ;0~`sER#W3otoKU*#@5%12rWY=t|^bzmOC^9%xA{%B( ztVRZoVTNI<^bJ^!@HFNuZrNWi<2PQ;*|4|BaS6I&|8bp>s_Afnnbv9~jDNo!L<8X? Q>WMm{cB9C(g($q|AGK#>DgXcg delta 1930 zcmaJ>drVtZ7(eHHw{I8^DIM?IOBpSNL4g9JZiE3rbis{*nr+HTd)-KQNn7F)!)qFK zBvW#XQ8sPjmMmF}IIh{E$ylQD7>#rL#}T4`fXQ6qlx!J>NHRUQEshpulkeR0d;ZS% z{k}7J7Y66y{j`J%gph;D`ftZ*euf`{VLfwG zK_`NXFc06sGK|4V=#&y-UWCFV6%=ZE#Xhmu)85_H8vg2)VB4T&_IBC4O+nA*@D?10CfH6^$pX1d{H*>Eq5f2ZNzf`#u0E%;+bwqRuI|oG zvCG@kP=7F}2>+KBQgd;JoDkv>@DLC0z@HF+1^5D7un)@MW0vp%q48Pq$$CzogQGKO zrLwGmnqw)9RAH{veT4h58z00~*h-DuBDGp}J(t4a60Bt~M6cMov3zF8;yUi^Iu>ck zNak<>);itph=6oy+|ra7uJ&}L?g+d9`{7xrg*^=CLqhjdB_=8WV{K;e%m|+8Qd`w$ zN0b8$0pBFAkbB^hJ~{6K>bv$H z^IJi%!oq(Cy%y3mZt+#8ufwZlSI4k~V2PRLfi8^;64(4U5RGP{`4PluG$D^Q1Zxt$ zc^~u~V2w_mB8O8EPQ@2U5tt<-r^WQ{$s5y|v~hYT<(aHbndyzGJbIqV;FKvdv;z(VKf&j43fiC&Vj2H0khh7GI9M+; z2we#5pkFchAixjUG8JeyE~#;L@gW-W5o@s(H*FdJg@pJS6|x0st?3F>jtk@}jJO;8 zli2EQ;xg?Bm}xB&At2DzxjcGfE)T~__!$Mqok4Jh(PN2>%r;wu&0H+Ea5%(w7N>l-DOU@Z7ZXL zj(VROctQaGd}EkUQ7Hx9ENoon)^@jG8Hz6qL9sm6cJFxit-|x(_Ol0QFa9vX`qg8XsoS!iQi;zU5|VWWn*Hw zCq9qZ8|=lfBVT2(+wq$lwm7PXku3;ypsc2e-?Yq8acrMCSw#=znnK$ia**rG4anys zMniiJ<<>^y4EeP*HXLZFV`1S6OdAy(yo;s2KxsH^r`NK#=WhkNbxUHEYbEUdNB1uQ C&T3o$ diff --git a/templates/base.html b/templates/base.html index 6a35aa9d..69688764 100644 --- a/templates/base.html +++ b/templates/base.html @@ -116,6 +116,8 @@ + + + {% block js %} {% endblock %}