forked from expo/troggle
[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:
parent
a3e42d3b19
commit
85ada36973
@ -3,7 +3,7 @@ from django.contrib import admin
|
|||||||
from feincms.admin import editor
|
from feincms.admin import editor
|
||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
import django.forms as forms
|
import django.forms as forms
|
||||||
from expo.forms import LogbookEntryForm
|
from expo.forms import LogbookEntryForm, QMsFoundInlineForm
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
#from troggle.reversion.admin import VersionAdmin #django-reversion version control
|
#from troggle.reversion.admin import VersionAdmin #django-reversion version control
|
||||||
@ -29,13 +29,18 @@ class SurveyAdmin(TroggleModelAdmin):
|
|||||||
inlines = (ScannedImageInline,)
|
inlines = (ScannedImageInline,)
|
||||||
search_fields = ('expedition__year','wallet_number')
|
search_fields = ('expedition__year','wallet_number')
|
||||||
|
|
||||||
class QMInline(admin.TabularInline):
|
class QMsFoundInline(admin.TabularInline):
|
||||||
model=QM
|
#form=QMsFoundInlineForm
|
||||||
extra = 4
|
model=QM
|
||||||
|
fk_name='found_by'
|
||||||
|
|
||||||
|
class QMsTickedOffInline(admin.TabularInline):
|
||||||
|
model=QM
|
||||||
|
fk_name='ticked_off_by'
|
||||||
|
|
||||||
class PhotoInline(admin.TabularInline):
|
class PhotoInline(admin.TabularInline):
|
||||||
model = Photo
|
model = Photo
|
||||||
exclude = ['is_mugshot', ]
|
exclude = ['is_mugshot' ]
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
class PersonTripInline(admin.TabularInline):
|
class PersonTripInline(admin.TabularInline):
|
||||||
@ -47,22 +52,24 @@ class PersonTripInline(admin.TabularInline):
|
|||||||
class LogbookEntryAdmin(TroggleModelAdmin):
|
class LogbookEntryAdmin(TroggleModelAdmin):
|
||||||
prepopulated_fields = {'slug':("title",)}
|
prepopulated_fields = {'slug':("title",)}
|
||||||
search_fields = ('title','expedition__year')
|
search_fields = ('title','expedition__year')
|
||||||
inlines = (PersonTripInline, PhotoInline)
|
date_heirarchy = ('date')
|
||||||
|
inlines = (PersonTripInline, PhotoInline, QMsFoundInline, QMsTickedOffInline)
|
||||||
form = LogbookEntryForm
|
form = LogbookEntryForm
|
||||||
#inlines = (QMInline,) #doesn't work because QM has two foreignkeys to Logbookentry- need workaround
|
|
||||||
|
|
||||||
class PersonExpeditionInline(admin.TabularInline):
|
class PersonExpeditionInline(admin.TabularInline):
|
||||||
model = PersonExpedition
|
model = PersonExpedition
|
||||||
extra = 1
|
extra = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class PersonAdmin(TroggleModelAdmin):
|
class PersonAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('first_name','last_name')
|
search_fields = ('first_name','last_name')
|
||||||
inlines = (PersonExpeditionInline,)
|
inlines = (PersonExpeditionInline,)
|
||||||
|
|
||||||
class QMAdmin(TroggleModelAdmin):
|
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):
|
class PersonExpeditionAdmin(TroggleModelAdmin):
|
||||||
search_fields = ('person__first_name','expedition__year')
|
search_fields = ('person__first_name','expedition__year')
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
from django.forms import ModelForm
|
from django.forms import ModelForm
|
||||||
from models import Cave, Person, LogbookEntry
|
from models import Cave, Person, LogbookEntry, QM
|
||||||
import django.forms as forms
|
import django.forms as forms
|
||||||
from django.forms.formsets import formset_factory
|
from django.forms.formsets import formset_factory
|
||||||
from django.contrib.admin.widgets import AdminDateWidget
|
from django.contrib.admin.widgets import AdminDateWidget
|
||||||
@ -37,4 +37,15 @@ class LogbookEntryForm(ModelForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(LogbookEntryForm, self).__init__(*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
|
||||||
|
|
||||||
|
|
@ -529,7 +529,7 @@ class QM(TroggleModel):
|
|||||||
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
||||||
found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True )
|
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)
|
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=(
|
GRADE_CHOICES=(
|
||||||
('A', 'A: Large obvious lead'),
|
('A', 'A: Large obvious lead'),
|
||||||
('B', 'B: Average 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
|
#the below are unneeded- instead use the date fields of the QM's trips
|
||||||
#dateFound = models.DateField(blank=True)
|
#dateFound = models.DateField(blank=True)
|
||||||
#dateKilled = 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
|
QMnumber=str(self.found_by.cave)+'-'+str(self.found_by.date.year)+"-"+str(self.number)+self.grade
|
||||||
return str(QMnumber)
|
return str(QMnumber)
|
||||||
|
|
||||||
@ -591,7 +591,7 @@ class Photo(TroggleImageModel):
|
|||||||
#object_id = models.PositiveIntegerField()
|
#object_id = models.PositiveIntegerField()
|
||||||
#location = generic.GenericForeignKey('content_type', 'object_id')
|
#location = generic.GenericForeignKey('content_type', 'object_id')
|
||||||
|
|
||||||
def __str__(self):
|
def __unicode__(self):
|
||||||
return self.caption
|
return self.caption
|
||||||
|
|
||||||
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
|
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
|
||||||
@ -623,7 +623,7 @@ class ScannedImage(TroggleImageModel):
|
|||||||
def correctURL(self):
|
def correctURL(self):
|
||||||
return string.replace(self.file.url,r'#',r'%23')
|
return string.replace(self.file.url,r'#',r'%23')
|
||||||
|
|
||||||
def __str__(self):
|
def __unicode__(self):
|
||||||
return get_scan_path(self,'')
|
return get_scan_path(self,'')
|
||||||
|
|
||||||
class Survey(TroggleModel):
|
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_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)
|
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)
|
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)
|
return self.expedition.year+"#"+"%02d" % int(self.wallet_number)
|
||||||
|
|
||||||
def notes(self):
|
def notes(self):
|
||||||
|
@ -35,6 +35,7 @@ def frontpage(request):
|
|||||||
logbookentry = LogbookEntry
|
logbookentry = LogbookEntry
|
||||||
cave = Cave
|
cave = Cave
|
||||||
photo = Photo
|
photo = Photo
|
||||||
|
from django.contrib.admin.templatetags import log
|
||||||
return render_response(request,'frontpage.html', locals())
|
return render_response(request,'frontpage.html', locals())
|
||||||
|
|
||||||
def todo(request):
|
def todo(request):
|
||||||
|
@ -33,6 +33,7 @@ div.logbookentry p
|
|||||||
margin:10px;
|
margin:10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
div#content div#col2
|
div#content div#col2
|
||||||
{
|
{
|
||||||
float:right;
|
float:right;
|
||||||
@ -47,7 +48,6 @@ div#content h2
|
|||||||
padding-bottom:30px;
|
padding-bottom:30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
table.prevnextexpeditions
|
table.prevnextexpeditions
|
||||||
{
|
{
|
||||||
width:100%;
|
width:100%;
|
||||||
@ -117,7 +117,7 @@ hr{
|
|||||||
div.centre img { vertical-align: middle; }
|
div.centre img { vertical-align: middle; }
|
||||||
|
|
||||||
h1 { text-align: center; font-size: 210%; display: inline;}
|
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}
|
h3 { color: #000 text-align:left; border-bottom:thin solid black; margin-bottom:1em; margin-top:1em; font-weight:bold}
|
||||||
h4 { color: #0d664c; }
|
h4 { color: #0d664c; }
|
||||||
h4.navbar {line-height: 0px;}
|
h4.navbar {line-height: 0px;}
|
||||||
@ -362,3 +362,46 @@ div#difflistajax
|
|||||||
border: thin green solid;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -3,11 +3,37 @@
|
|||||||
|
|
||||||
{% block title %}Cambridge Expeditions to Austria{% endblock %}
|
{% block title %}Cambridge Expeditions to Austria{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div id="col2">
|
<div id="related">
|
||||||
Recent edits
|
<h2>Recent Actions</h2>
|
||||||
</div>
|
{% 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">
|
<div id="col1">
|
||||||
<h3>Welcome</h3>
|
<h3>Welcome</h3>
|
||||||
|
@ -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>to activate your account. Do this within {{ expiration_days }} days, or else you'll have to sign up again.</P>
|
||||||
|
|
||||||
<P>Yours,<BR>
|
<P>Yours,<BR>
|
||||||
The magical troggle</P>
|
The magical troggle</P>
|
||||||
|
Loading…
Reference in New Issue
Block a user