2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 08:41:51 +00:00

[svn] * Added admin inlines for QMs in LogbookEntry model

* Added QM list edit view
* Fixed "recent changes" box on front page
This commit is contained in:
substantialnoninfringinguser 2009-06-10 00:05:02 +01:00
parent a3e42d3b19
commit 85ada36973
7 changed files with 111 additions and 23 deletions

View File

@ -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')

View File

@ -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()
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

View File

@ -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):

View File

@ -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):

View File

@ -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;
}

View File

@ -3,11 +3,37 @@
{% block title %}Cambridge Expeditions to Austria{% endblock %}
{% block content %}
<div id="col2">
Recent edits
</div>
<div id="related">
<h2>Recent Actions</h2>
{% load log %}
{% get_admin_log 10 as admin_log %}
{% if not admin_log %}
<p>No recent actions</p>
{% else %}
<ul class="actionlist">
{% for entry in admin_log %}
<li class="{% if entry.is_addition %}addlink{% endif %}{% if entry.is_change %}changelink{% endif %}{% if entry.is_deletion %}deletelink{% endif %}">
{% if entry.is_deletion %}
{{ entry.object_repr }}
{% else %}
<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
{% endif %}
<br/>
{% if entry.content_type %}
<span class="mini quiet">{% filter capfirst %}{{entry.content_type.name}}{% endfilter %}</span>
{% else %}
<span class="mini quiet">Unknown content</span>
{% endif %}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
<div id="col1">
<h3>Welcome</h3>

View File

@ -7,4 +7,4 @@
<P>to activate your account. Do this within {{ expiration_days }} days, or else you'll have to sign up again.</P>
<P>Yours,<BR>
The magical troggle</P>
The magical troggle</P>