[svn] Various bug fixes, using more raw_id fields in admin so it loads faster. I had to put onLoad="contentHeight();" back into the base template. This is a bad solution, I would rather use Martin's, but it wasn't working.

This commit is contained in:
substantialnoninfringinguser 2009-07-22 16:18:00 +01:00
parent e5033c7b69
commit 57ede091c4
11 changed files with 36 additions and 26 deletions

@ -57,6 +57,7 @@ class PersonTripInline(admin.TabularInline):
#class LogbookEntryAdmin(VersionAdmin): #class LogbookEntryAdmin(VersionAdmin):
class LogbookEntryAdmin(TroggleModelAdmin): class LogbookEntryAdmin(TroggleModelAdmin):
prepopulated_fields = {'slug':("title",)} prepopulated_fields = {'slug':("title",)}
raw_id_fields = ('cave','author')
search_fields = ('title','expedition__year') search_fields = ('title','expedition__year')
date_heirarchy = ('date') date_heirarchy = ('date')
inlines = (PersonTripInline, PhotoInline, QMsFoundInline) inlines = (PersonTripInline, PhotoInline, QMsFoundInline)

@ -145,7 +145,8 @@ def wiki_to_html_short(value, autoescape=None):
#make subcave links #make subcave links
value = re.sub("\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%s/subcave/\1/">\2</a>' % url_root, value, re.DOTALL) value = re.sub("\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%s/subcave/\1/">\2</a>' % url_root, value, re.DOTALL)
#make cavedescription links #make cavedescription links
value = re.sub("\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%s/cavedescription/\2/">\2</a>' % url_root, value, re.DOTALL) value = re.sub("\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%s/cavedescription/\1/">\2</a>' % url_root, value, re.DOTALL)
#Make lists from lines starting with lists of [stars and hashes] #Make lists from lines starting with lists of [stars and hashes]

@ -37,7 +37,7 @@ def qm(request,cave_id,qm_id,year,grade=None):
return render_with_context(request,'qm.html',locals()) return render_with_context(request,'qm.html',locals())
except QM.DoesNotExist: except QM.DoesNotExist:
url=urlparse.urljoin(settings.URL_ROOT, r'/admin/expo/qm/add/'+'?'+ r'number=' + qm_id) url=urlparse.urljoin(settings.URL_ROOT, r'/admin/core/qm/add/'+'?'+ r'number=' + qm_id)
if grade: if grade:
url += r'&grade=' + grade url += r'&grade=' + grade
return HttpResponseRedirect(url) return HttpResponseRedirect(url)
@ -76,5 +76,4 @@ def survey(request,year,wallet_number):
def cave_description(request, cavedescription_name): def cave_description(request, cavedescription_name):
cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name) cave_description = get_object_or_404(CaveDescription, short_name = cavedescription_name)
print cave_description.long_name
return render_with_context(request,'cave_description.html', locals()) return render_with_context(request,'cave_description.html', locals())

@ -161,7 +161,7 @@ def logbook_entry_suggestions(request):
Generates a html box with suggestions about what to do with QMs Generates a html box with suggestions about what to do with QMs
in logbook entry text. in logbook entry text.
""" """
unwiki_QM_pattern=r"(?P<whole>(?P<explorer_code>[ABC]?)(?P<cave>\d*)-?(?P<year>\d\d\d?\d?)-(?P<number>\d\d)(?P<grade>[ABCDXV]?)(?=\s))" unwiki_QM_pattern=r"(?P<whole>(?P<explorer_code>[ABC]?)(?P<cave>\d*)-?(?P<year>\d\d\d?\d?)-(?P<number>\d\d)(?P<grade>[ABCDXV]?))"
unwiki_QM_pattern=re.compile(unwiki_QM_pattern) unwiki_QM_pattern=re.compile(unwiki_QM_pattern)
#wikilink_QM_pattern=settings.QM_PATTERN #wikilink_QM_pattern=settings.QM_PATTERN
@ -174,18 +174,24 @@ def logbook_entry_suggestions(request):
print unwiki_QMs print unwiki_QMs
for qm in unwiki_QMs: for qm in unwiki_QMs:
if len(qm['year'])==2: #try:
if int(qm['year'])<50: if len(qm['year'])==2:
qm['year']='20'+qm['year'] if int(qm['year'])<50:
else: qm['year']='20'+qm['year']
qm['year']='19'+qm['year'] else:
qm['year']='19'+qm['year']
temp_QM=QM(found_by=lbo,number=qm['number'],grade=qm['grade']) if lbo.date.year!=int(qm['year']):
try: try:
temp_QM.grade=unwiki_QM['grade'] lbo=LogbookEntry.objects.get(date__year=qm['year'],title__icontains="placeholder for QMs in")
except: except:
pass print "failed to get placeholder for year "+str(qm['year'])
qm['wikilink']=temp_QM.wiki_link()
temp_QM=QM(found_by=lbo,number=qm['number'],grade=qm['grade'])
temp_QM.grade=qm['grade']
qm['wikilink']=temp_QM.wiki_link()
#except:
#print 'failed'
print unwiki_QMs print unwiki_QMs

@ -39,7 +39,7 @@ def parseDescriptions():
cd.save() cd.save()
def parseDescriptionsInCaveObjects(): def parseDescriptionsOnCaveObjects():
for cave in models.Cave.objects.all(): for cave in models.Cave.objects.all():
cave.underground_description=html_to_wiki(unicode(cave.underground_description)) cave.underground_description=html_to_wiki(unicode(cave.underground_description))
cave.save() cave.save()

@ -13,7 +13,7 @@
{% block head %}{% endblock %} {% block head %}{% endblock %}
</head> </head>
<body> <body onLoad="contentHeight();">
<div id="header"> <div id="header">
<h1>CUCC Expeditions to Austria: 1976 - 2009</h1> <h1>CUCC Expeditions to Austria: 1976 - 2009</h1>

@ -59,7 +59,7 @@
{% for personexpedition in expedition.personexpedition_set.all %} {% for personexpedition in expedition.personexpedition_set.all %}
<tr> <tr>
<td class="name"> <td class="name">
<a href="">{{ personexpedition.person }}</a> <a href="{{ personexpedition.person.get_absolute_url }}">{{ personexpedition.person }}</a>
</td> </td>
{% if personexpedition.ListDaysTF %} {% if personexpedition.ListDaysTF %}

@ -1,6 +1,6 @@
{% extends "cavebase.html" %} {% extends "cavebase.html" %}
{% load wiki_markup %} {% load wiki_markup %}
{% block title %} {{cave_description.short_name}} {% endblock title %} {% block title %} {{cave_description}} {% endblock title %}
{% block editLink %}<a href={{cave_description.get_admin_url}}>Edit description {{cave_description}}</a>{% endblock %} {% block editLink %}<a href={{cave_description.get_admin_url}}>Edit description {{cave_description}}</a>{% endblock %}
{% block contentheader %} {% block contentheader %}

@ -31,7 +31,7 @@
<table> <table>
{% for personrole in survexblock.GetPersonroles %} {% for personrole in survexblock.GetPersonroles %}
<tr> <tr>
<td><a href="{{personrole.get_absolute_url}}">{{personrole.person}}</a></td> <td><a href="{{personrole.person.get_absolute_url}}">{{personrole.person}}</a></td>
<td>{{personrole.roles}}</td> <td>{{personrole.roles}}</td>
</tr> </tr>
{% endfor %} {% endfor %}

@ -32,7 +32,8 @@ urlpatterns = patterns('',
url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"), url(r'^survexblock/(.+)$', views_caves.survexblock, name="survexblock"),
url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"), url(r'^cave/(?P<cave_id>[^/]+)/?$', views_caves.cave, name="cave"),
url(r'^cavedescription/(?P<cavedescription_name>[^/]*)/$', views_caves.cave_description, name="cavedescription"), url(r'^cavedescription/(?P<cavedescription_name>[^/]+)/?$', views_caves.cave_description, name="cavedescription"),
url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"),
#url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'), #url(r'^cavehref/(.+)$', views_caves.cave, name="cave"),url(r'cave'),
url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"), url(r'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"),

@ -102,7 +102,7 @@ def href_to_wikilinks(matchobj):
if res: if res:
return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]' return r'[[cavedescription:'+res[0].short_name+'|'+res[0].long_name+']]'
else: else:
return matchobj return matchobj.group()
#except: #except:
#print 'fail' #print 'fail'
@ -115,13 +115,15 @@ re_subs = [(re.compile(r"\<b[^>]*\>(.*?)\</b\>", re.DOTALL), r"'''\1'''"),
(re.compile(r"\<h4[^>]*\>(.*?)\</h4\>", re.DOTALL), r"====\1===="), (re.compile(r"\<h4[^>]*\>(.*?)\</h4\>", re.DOTALL), r"====\1===="),
(re.compile(r"\<h5[^>]*\>(.*?)\</h5\>", re.DOTALL), r"=====\1====="), (re.compile(r"\<h5[^>]*\>(.*?)\</h5\>", re.DOTALL), r"=====\1====="),
(re.compile(r"\<h6[^>]*\>(.*?)\</h6\>", re.DOTALL), r"======\1======"), (re.compile(r"\<h6[^>]*\>(.*?)\</h6\>", re.DOTALL), r"======\1======"),
(re.compile(r'(<a href="?(?P<target>.*)"?>)?<img class="?(?P<class>\w*)"? src="?t/?(?P<source>[\w/\.]*)"?(?P<rest>></img>|\s/>(</a>)?)', re.DOTALL),r'[[display:\g<class> photo:\g<source>]]'), #
(re.compile(r"\<a\s+id=['\"]([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[subcave:\1|\2]]"), #assumes that all links with id attributes are subcaves. Not great. (re.compile(r"\<a\s+id=['\"]([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[subcave:\1|\2]]"), #assumes that all links with id attributes are subcaves. Not great.
#interpage link needed #interpage link needed
(re.compile(r"\<a\s+href=['\"]#([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are subcaves. Not great. (re.compile(r"\<a\s+href=['\"]#([^'\"]*)['\"]\s*\>(.*?)\</a\>", re.DOTALL), r"[[cavedescription:\1|\2]]"), #assumes that all links with target ids are cave descriptions. Not great.
(re.compile(r"\[\<a\s+href=['\"][^'\"]*['\"]\s+id=['\"][^'\"]*['\"]\s*\>([^\s]*).*?\</a\>\]", re.DOTALL), r"[[qm:\1]]"), (re.compile(r"\[\<a\s+href=['\"][^'\"]*['\"]\s+id=['\"][^'\"]*['\"]\s*\>([^\s]*).*?\</a\>\]", re.DOTALL), r"[[qm:\1]]"),
# BUGGED! #BUGGED!
# (re.compile(r'<a\shref="?(?P<target>.*)"?>(?P<text>.*)</a>'),href_to_wikilinks) (re.compile(r'<a\shref="?(?P<target>.*)"?>(?P<text>.*)</a>'),href_to_wikilinks),
] ]