From 85ada3697341c95f1f07890ac1cca4190d6d4d2b Mon Sep 17 00:00:00 2001 From: substantialnoninfringinguser Date: Wed, 10 Jun 2009 00:05:02 +0100 Subject: [PATCH] [svn] * Added admin inlines for QMs in LogbookEntry model * Added QM list edit view * Fixed "recent changes" box on front page --- expo/admin.py | 27 ++++++----- expo/forms.py | 15 ++++++- expo/models.py | 10 ++--- expo/views_other.py | 1 + media/css/main3.css | 47 +++++++++++++++++++- templates/frontpage.html | 32 +++++++++++-- templates/registration/activation_email.html | 2 +- 7 files changed, 111 insertions(+), 23 deletions(-) diff --git a/expo/admin.py b/expo/admin.py index d8adbe2..ffa00c5 100644 --- a/expo/admin.py +++ b/expo/admin.py @@ -3,7 +3,7 @@ from django.contrib import admin from feincms.admin import editor from django.forms import ModelForm import django.forms as forms -from expo.forms import LogbookEntryForm +from expo.forms import LogbookEntryForm, QMsFoundInlineForm from django.http import HttpResponse from django.core import serializers #from troggle.reversion.admin import VersionAdmin #django-reversion version control @@ -29,13 +29,18 @@ class SurveyAdmin(TroggleModelAdmin): inlines = (ScannedImageInline,) search_fields = ('expedition__year','wallet_number') -class QMInline(admin.TabularInline): - model=QM - extra = 4 +class QMsFoundInline(admin.TabularInline): + #form=QMsFoundInlineForm + model=QM + fk_name='found_by' + +class QMsTickedOffInline(admin.TabularInline): + model=QM + fk_name='ticked_off_by' class PhotoInline(admin.TabularInline): model = Photo - exclude = ['is_mugshot', ] + exclude = ['is_mugshot' ] extra = 1 class PersonTripInline(admin.TabularInline): @@ -47,22 +52,24 @@ class PersonTripInline(admin.TabularInline): class LogbookEntryAdmin(TroggleModelAdmin): prepopulated_fields = {'slug':("title",)} search_fields = ('title','expedition__year') - inlines = (PersonTripInline, PhotoInline) + date_heirarchy = ('date') + inlines = (PersonTripInline, PhotoInline, QMsFoundInline, QMsTickedOffInline) form = LogbookEntryForm - #inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround class PersonExpeditionInline(admin.TabularInline): model = PersonExpedition extra = 1 - - class PersonAdmin(TroggleModelAdmin): search_fields = ('first_name','last_name') inlines = (PersonExpeditionInline,) class QMAdmin(TroggleModelAdmin): - search_fields = ('found_by__cave__kataster_number','number') + search_fields = ('found_by__cave__kataster_number','number','found_by__date__year') + list_display = ('__unicode__','grade','found_by','ticked_off_by') + list_display_links = ('__unicode__',) + list_editable = ('found_by','ticked_off_by','grade') + list_per_page = 20 class PersonExpeditionAdmin(TroggleModelAdmin): search_fields = ('person__first_name','expedition__year') diff --git a/expo/forms.py b/expo/forms.py index 2225b0c..9573c18 100644 --- a/expo/forms.py +++ b/expo/forms.py @@ -1,5 +1,5 @@ from django.forms import ModelForm -from models import Cave, Person, LogbookEntry +from models import Cave, Person, LogbookEntry, QM import django.forms as forms from django.forms.formsets import formset_factory from django.contrib.admin.widgets import AdminDateWidget @@ -37,4 +37,15 @@ class LogbookEntryForm(ModelForm): def __init__(self, *args, **kwargs): super(LogbookEntryForm, self).__init__(*args, **kwargs) - self.fields['text'].help_text=self.wikiLinkHints() \ No newline at end of file + self.fields['text'].help_text=self.wikiLinkHints() + +class QMsFoundInlineForm(ModelForm): + class Meta: + model = QM + exclude = 'ticked_off_by' + + def __init__(self, *args, **kwargs): + super(QMsFoundInlineForm, self).__init__(*args, **kwargs) + #self.fields['number'].initial=nextQMinyear()#work on that one + + \ No newline at end of file diff --git a/expo/models.py b/expo/models.py index 13d0b7b..3ab53aa 100644 --- a/expo/models.py +++ b/expo/models.py @@ -529,7 +529,7 @@ class QM(TroggleModel): #"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment" found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True ) ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',null=True,blank=True) - number = models.IntegerField() + number = models.IntegerField(help_text="this is the sequential number in the year") GRADE_CHOICES=( ('A', 'A: Large obvious lead'), ('B', 'B: Average lead'), @@ -548,7 +548,7 @@ class QM(TroggleModel): #the below are unneeded- instead use the date fields of the QM's trips #dateFound = models.DateField(blank=True) #dateKilled = models.DateField(blank=True) - def __str__(self): + def __unicode__(self): QMnumber=str(self.found_by.cave)+'-'+str(self.found_by.date.year)+"-"+str(self.number)+self.grade return str(QMnumber) @@ -591,7 +591,7 @@ class Photo(TroggleImageModel): #object_id = models.PositiveIntegerField() #location = generic.GenericForeignKey('content_type', 'object_id') - def __str__(self): + def __unicode__(self): return self.caption scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL) @@ -623,7 +623,7 @@ class ScannedImage(TroggleImageModel): def correctURL(self): return string.replace(self.file.url,r'#',r'%23') - def __str__(self): + def __unicode__(self): return get_scan_path(self,'') class Survey(TroggleModel): @@ -644,7 +644,7 @@ class Survey(TroggleModel): integrated_into_main_sketch_on = models.DateField(blank=True,null=True) integrated_into_main_sketch_by = models.ForeignKey('Person' ,related_name='integrated_into_main_sketch_by', blank=True,null=True) rendered_image = models.ImageField(upload_to='renderedSurveys',blank=True,null=True) - def __str__(self): + def __unicode__(self): return self.expedition.year+"#"+"%02d" % int(self.wallet_number) def notes(self): diff --git a/expo/views_other.py b/expo/views_other.py index f5944a6..c6da4b3 100644 --- a/expo/views_other.py +++ b/expo/views_other.py @@ -35,6 +35,7 @@ def frontpage(request): logbookentry = LogbookEntry cave = Cave photo = Photo + from django.contrib.admin.templatetags import log return render_response(request,'frontpage.html', locals()) def todo(request): diff --git a/media/css/main3.css b/media/css/main3.css index be613a2..3c229e0 100644 --- a/media/css/main3.css +++ b/media/css/main3.css @@ -33,6 +33,7 @@ div.logbookentry p margin:10px; } + div#content div#col2 { float:right; @@ -47,7 +48,6 @@ div#content h2 padding-bottom:30px; } - table.prevnextexpeditions { width:100%; @@ -117,7 +117,7 @@ hr{ div.centre img { vertical-align: middle; } h1 { text-align: center; font-size: 210%; display: inline;} -h2 { color: #009900; } +h2 { } h3 { color: #000 text-align:left; border-bottom:thin solid black; margin-bottom:1em; margin-top:1em; font-weight:bold} h4 { color: #0d664c; } h4.navbar {line-height: 0px;} @@ -362,3 +362,46 @@ div#difflistajax border: thin green solid; } +} + +/*The below are stolen from django admin css*/ +.addlink { + background:transparent url("../icon_addlink.gif") no-repeat scroll 0 0.2em; + padding-left:12px; +} + +.quiet, a.quiet:link, a.quiet:visited { + color:#999999 !important; + font-weight:normal !important; +} + +.mini { + font-size:9px; +} + +/*this is for the related objects box on the right hand side, formerly called "col2." transition is in progress.*/ + +ul.actionlist li +{ + list-style-type:none; +} + +div#related h2 +{ + padding-bottom:0px; + font-size:100%; + text-align:left; + background:#EEEEEE url(../nav-bg.gif) repeat-x scroll left bottom; + color:#666666; + margin: 0px; +} + +div#related +{ + width:200px; + float:right; + border: thin solid black; + background:#EEEEEE; + color:#666666; +} + diff --git a/templates/frontpage.html b/templates/frontpage.html index a193771..20028a3 100644 --- a/templates/frontpage.html +++ b/templates/frontpage.html @@ -3,11 +3,37 @@ {% block title %}Cambridge Expeditions to Austria{% endblock %} + + {% block content %} -
-Recent edits -
+ +

Welcome

diff --git a/templates/registration/activation_email.html b/templates/registration/activation_email.html index e8f846b..3d56009 100644 --- a/templates/registration/activation_email.html +++ b/templates/registration/activation_email.html @@ -7,4 +7,4 @@

to activate your account. Do this within {{ expiration_days }} days, or else you'll have to sign up again.

Yours,
-The magical troggle

+The magical troggle