forked from expo/troggle
[svn] Fixed a bug with QMs with numbers between 1 and 10, and fixed the links in the recent changes box.
This commit is contained in:
parent
d89a4b6958
commit
eed4fea255
@ -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, QMsFoundInlineForm
|
from expo.forms import LogbookEntryForm
|
||||||
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
|
||||||
@ -30,7 +30,6 @@ class SurveyAdmin(TroggleModelAdmin):
|
|||||||
search_fields = ('expedition__year','wallet_number')
|
search_fields = ('expedition__year','wallet_number')
|
||||||
|
|
||||||
class QMsFoundInline(admin.TabularInline):
|
class QMsFoundInline(admin.TabularInline):
|
||||||
#form=QMsFoundInlineForm
|
|
||||||
model=QM
|
model=QM
|
||||||
fk_name='found_by'
|
fk_name='found_by'
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ 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
|
||||||
import string
|
import string
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
class CaveForm(ModelForm):
|
class CaveForm(ModelForm):
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -18,6 +19,13 @@ class LogbookEntryForm(ModelForm):
|
|||||||
model = LogbookEntry
|
model = LogbookEntry
|
||||||
|
|
||||||
def wikiLinkHints(LogbookEntry=None):
|
def wikiLinkHints(LogbookEntry=None):
|
||||||
|
"""
|
||||||
|
This function returns html-formatted paragraphs for each of the
|
||||||
|
wikilink types that are related to this logbookentry. Each paragraph
|
||||||
|
contains a list of all of the related wikilinks.
|
||||||
|
|
||||||
|
Perhaps an admin javascript solution would be better.
|
||||||
|
"""
|
||||||
res = ["Please use the following wikilinks, which are related to this logbook entry:"]
|
res = ["Please use the following wikilinks, which are related to this logbook entry:"]
|
||||||
|
|
||||||
res.append(r'</p><p style="float: left;"><b>QMs found:</b>')
|
res.append(r'</p><p style="float: left;"><b>QMs found:</b>')
|
||||||
@ -38,14 +46,3 @@ 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
|
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ class TroggleModel(models.Model):
|
|||||||
return self._meta.object_name
|
return self._meta.object_name
|
||||||
|
|
||||||
def get_admin_url(self):
|
def get_admin_url(self):
|
||||||
return settings.URL_ROOT + "/admin/expo/" + self.object_name().lower() + "/" + str(self.pk)
|
return urlparse.urljoin(settings.URL_ROOT, "/admin/expo/" + self.object_name().lower() + "/" + str(self.pk))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
@ -364,8 +364,6 @@ class Cave(TroggleModel):
|
|||||||
#return settings.URL_ROOT + '/cave/' + href + '/'
|
#return settings.URL_ROOT + '/cave/' + href + '/'
|
||||||
return urlparse.urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,}))
|
return urlparse.urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
if self.kataster_number:
|
if self.kataster_number:
|
||||||
if self.kat_area():
|
if self.kat_area():
|
||||||
@ -385,8 +383,10 @@ class Cave(TroggleModel):
|
|||||||
for a in self.area.all():
|
for a in self.area.all():
|
||||||
if a.kat_area():
|
if a.kat_area():
|
||||||
return a.kat_area()
|
return a.kat_area()
|
||||||
|
|
||||||
def entrances(self):
|
def entrances(self):
|
||||||
return CaveAndEntrance.objects.filter(cave=self)
|
return CaveAndEntrance.objects.filter(cave=self)
|
||||||
|
|
||||||
def entrancelist(self):
|
def entrancelist(self):
|
||||||
rs = []
|
rs = []
|
||||||
res = ""
|
res = ""
|
||||||
@ -415,7 +415,12 @@ class Cave(TroggleModel):
|
|||||||
res += "–" + prevR
|
res += "–" + prevR
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
def nextQMnumber(self, year=datetime.date.today().year):
|
||||||
|
"""
|
||||||
|
Given a cave and the current year, returns the next QM number.
|
||||||
|
"""
|
||||||
|
res=QM.objects.filter(found_by__date__year=year, found_by__cave=self).order_by('-number')[0]
|
||||||
|
return res.number+1
|
||||||
|
|
||||||
class OtherCaveName(TroggleModel):
|
class OtherCaveName(TroggleModel):
|
||||||
name = models.CharField(max_length=160)
|
name = models.CharField(max_length=160)
|
||||||
|
@ -57,11 +57,20 @@ def wiki_to_html_short(value, autoescape=None):
|
|||||||
value = re.sub("''([^']+)''", r"<i>\1</i>", value, re.DOTALL)
|
value = re.sub("''([^']+)''", r"<i>\1</i>", value, re.DOTALL)
|
||||||
#make cave links
|
#make cave links
|
||||||
value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%s/cave/\1/">\1</a>' % settings.URL_ROOT, value, re.DOTALL)
|
value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%s/cave/\1/">\1</a>' % settings.URL_ROOT, value, re.DOTALL)
|
||||||
|
#make people links
|
||||||
|
|
||||||
|
|
||||||
#function for replacing wikicode qm links with html qm links
|
qmMatchPattern="\[\[\s*cave:([^\s]+)\s*\s*\QM:(\d*)-(\d*)([ABCDX]?)\]\]"
|
||||||
|
|
||||||
def qmrepl(matchobj):
|
def qmrepl(matchobj):
|
||||||
|
"""
|
||||||
|
A function for replacing wikicode qm links with html qm links.
|
||||||
|
Given a matchobj matching a wikilink in the format
|
||||||
|
[[cave:204 QM:1999-24C]] where the grade (C) is optional.
|
||||||
|
If the QM does not exist, the function will return a link for creating it.
|
||||||
|
"""
|
||||||
if len(matchobj.groups())==4:
|
if len(matchobj.groups())==4:
|
||||||
|
# if there are four matched groups, then
|
||||||
grade=matchobj.groups()[3]
|
grade=matchobj.groups()[3]
|
||||||
else:
|
else:
|
||||||
grade=''
|
grade=''
|
||||||
@ -74,7 +83,7 @@ def wiki_to_html_short(value, autoescape=None):
|
|||||||
return url
|
return url
|
||||||
|
|
||||||
#make qm links
|
#make qm links
|
||||||
value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\QM:(\d*)-(\d*)([ABCDX]?)\]\]",qmrepl, value, re.DOTALL)
|
value = re.sub(qmMatchPattern,qmrepl, value, re.DOTALL)
|
||||||
|
|
||||||
#qms=qmfinder.search(value)
|
#qms=qmfinder.search(value)
|
||||||
#for qm in qms:
|
#for qm in qms:
|
||||||
|
@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse
|
|||||||
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
|
from troggle.alwaysUseRequestContext import render_response # see views_logbooks for explanation on this.
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
import re
|
import re, urlparse
|
||||||
|
|
||||||
def getCave(cave_id):
|
def getCave(cave_id):
|
||||||
"""Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm."""
|
"""Returns a cave object when given a cave name or number. It is used by views including cavehref, ent, and qm."""
|
||||||
@ -33,7 +33,7 @@ def qm(request,cave_id,qm_id,year,grade=None):
|
|||||||
return render_response(request,'qm.html',locals())
|
return render_response(request,'qm.html',locals())
|
||||||
|
|
||||||
except QM.DoesNotExist:
|
except QM.DoesNotExist:
|
||||||
url= settings.URL_ROOT + r'/admin/expo/qm/add/?'+ r'number=' + qm_id
|
url=urlparse.urljoin(settings.URL_ROOT, r'/admin/expo/qm/add/'+'?'+ r'number=' + qm_id)
|
||||||
if grade:
|
if grade:
|
||||||
url += r'&grade=' + grade
|
url += r'&grade=' + grade
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
@ -405,3 +405,26 @@ div#related
|
|||||||
color:#666666;
|
color:#666666;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.addlink {
|
||||||
|
padding-left: 12px;
|
||||||
|
background: url(../icon_addlink.gif) 0 .2em no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.changelink {
|
||||||
|
padding-left: 12px;
|
||||||
|
background: url(../icon_changelink.gif) 0 .2em no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
.deletelink {
|
||||||
|
padding-left: 12px;
|
||||||
|
background: url(../icon_deletelink.gif) 0 .25em no-repeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.deletelink:link, a.deletelink:visited {
|
||||||
|
color: #CC3434;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.deletelink:hover {
|
||||||
|
color: #993333;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
{% if entry.is_deletion %}
|
{% if entry.is_deletion %}
|
||||||
{{ entry.object_repr }}
|
{{ entry.object_repr }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
|
<a href="admin/{{ entry.get_admin_url }}">{{ entry.object_repr }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<br/>
|
<br/>
|
||||||
{% if entry.content_type %}
|
{% if entry.content_type %}
|
||||||
|
2
urls.py
2
urls.py
@ -40,7 +40,7 @@ urlpatterns = patterns('',
|
|||||||
#(r'^cavesearch', caveSearch),
|
#(r'^cavesearch', caveSearch),
|
||||||
|
|
||||||
|
|
||||||
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d\d)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),
|
url(r'^cave/(?P<cave_id>[^/]+)/(?P<year>\d\d\d\d)-(?P<qm_id>\d*)(?P<grade>[ABCDX]?)?$', views_caves.qm, name="qm"),
|
||||||
|
|
||||||
#url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"),
|
#url(r'^survex/(.*?)\.index$', views_survex.index, name="survexindex"),
|
||||||
url(r'^survex/(?P<survex_file>.*?)\.svx$', svx, name="svx"),
|
url(r'^survex/(?P<survex_file>.*?)\.svx$', svx, name="svx"),
|
||||||
|
Loading…
Reference in New Issue
Block a user