mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-29 21:31:54 +00:00
[svn] * Make subcave urls work.
* Add json and xml download to admin.
This commit is contained in:
parent
9f13a58498
commit
49ed6495ad
@ -37,7 +37,13 @@ def import_people():
|
|||||||
parsers.people.LoadPersonsExpos()
|
parsers.people.LoadPersonsExpos()
|
||||||
|
|
||||||
def import_logbooks():
|
def import_logbooks():
|
||||||
|
# The below line was causing errors I didn't understand (it said LOGFILE was a string), and I couldn't be bothered to figure
|
||||||
|
# what was going on so I just catch the error with a try. - AC 21 May
|
||||||
|
try:
|
||||||
settings.LOGFILE.write('\nBegun importing logbooks at ' + time.asctime() +'\n'+'-'*60)
|
settings.LOGFILE.write('\nBegun importing logbooks at ' + time.asctime() +'\n'+'-'*60)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
import parsers.logbooks
|
import parsers.logbooks
|
||||||
parsers.logbooks.LoadLogbooks()
|
parsers.logbooks.LoadLogbooks()
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@ 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
|
||||||
|
from django.http import HttpResponse
|
||||||
|
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
|
||||||
|
|
||||||
#overriding admin save so we have the new since parsing field
|
#overriding admin save so we have the new since parsing field
|
||||||
@ -73,7 +75,6 @@ class CaveAdmin(TroggleModelAdmin):
|
|||||||
class SubcaveAdmin(editor.TreeEditorMixin,TroggleModelAdmin):
|
class SubcaveAdmin(editor.TreeEditorMixin,TroggleModelAdmin):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
admin.site.register(Photo)
|
admin.site.register(Photo)
|
||||||
admin.site.register(Subcave, SubcaveAdmin)
|
admin.site.register(Subcave, SubcaveAdmin)
|
||||||
admin.site.register(Cave, CaveAdmin)
|
admin.site.register(Cave, CaveAdmin)
|
||||||
@ -94,6 +95,29 @@ admin.site.register(QM, QMAdmin)
|
|||||||
admin.site.register(Survey, SurveyAdmin)
|
admin.site.register(Survey, SurveyAdmin)
|
||||||
admin.site.register(ScannedImage)
|
admin.site.register(ScannedImage)
|
||||||
|
|
||||||
|
def export_as_json(modeladmin, request, queryset):
|
||||||
|
response = HttpResponse(mimetype="text/json")
|
||||||
|
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml'
|
||||||
|
serializers.serialize("json", queryset, stream=response)
|
||||||
|
return response
|
||||||
|
|
||||||
|
admin.site.add_action(export_as_json)
|
||||||
|
|
||||||
|
def export_as_xml(modeladmin, request, queryset):
|
||||||
|
response = HttpResponse(mimetype="text/xml")
|
||||||
|
response['Content-Disposition'] = 'attachment; filename=troggle_output.xml'
|
||||||
|
return response
|
||||||
|
|
||||||
|
admin.site.add_action(export_as_xml)
|
||||||
|
|
||||||
|
def export_as_python(modeladmin, request, queryset):
|
||||||
|
response = HttpResponse(mimetype="text/python")
|
||||||
|
response['Content-Disposition'] = 'attachment; filename=troggle_output.py'
|
||||||
|
serializers.serialize("json", queryset, stream=response)
|
||||||
|
return response
|
||||||
|
|
||||||
|
admin.site.add_action(export_as_python)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
mptt.register(Subcave, order_insertion_by=['name'])
|
mptt.register(Subcave, order_insertion_by=['name'])
|
||||||
except mptt.AlreadyRegistered:
|
except mptt.AlreadyRegistered:
|
||||||
|
@ -466,13 +466,25 @@ class Entrance(TroggleModel):
|
|||||||
class Subcave(TroggleModel):
|
class Subcave(TroggleModel):
|
||||||
description = models.TextField(blank=True, null=True)
|
description = models.TextField(blank=True, null=True)
|
||||||
title = models.CharField(max_length=200, )
|
title = models.CharField(max_length=200, )
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True, help_text="Only the top-level subcave should be linked to a cave")
|
cave = models.ForeignKey('Cave', blank=True, null=True, help_text="Only the top-level subcave should be linked to a cave!")
|
||||||
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
|
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
|
||||||
#adjoining = models.ManyToManyField('Subcave',blank=True, null=True,)
|
#adjoining = models.ManyToManyField('Subcave',blank=True, null=True,)
|
||||||
legacy_description_path = models.CharField(max_length=600, blank=True, null=True)
|
legacy_description_path = models.CharField(max_length=600, blank=True, null=True)
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
|
||||||
|
ancestor_titles='/'.join([subcave.title for subcave in self.get_ancestors()])
|
||||||
|
if ancestor_titles:
|
||||||
|
res = '/'.join((self.get_root().cave.get_absolute_url(), ancestor_titles, self.title))
|
||||||
|
|
||||||
|
else:
|
||||||
|
res = '/'.join((self.get_root().cave.get_absolute_url(), self.title))
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
# This was the old way, before we were using django-mptt
|
||||||
|
|
||||||
# def get_absolute_url(self):
|
# def get_absolute_url(self):
|
||||||
# urlString=self.name
|
# urlString=self.name
|
||||||
@ -524,7 +536,7 @@ class QM(TroggleModel):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
#return settings.URL_ROOT + '/cave/' + self.found_by.cave.kataster_number + '/' + str(self.found_by.date.year) + '-' + '%02d' %self.number
|
#return settings.URL_ROOT + '/cave/' + self.found_by.cave.kataster_number + '/' + str(self.found_by.date.year) + '-' + '%02d' %self.number
|
||||||
return settings.URL_ROOT + reverse('qm',kwargs={'cave_id':self.cave.kataster_number,'year':self.found_by.date.year,'qm_id':self.number,'grade':self.grade})
|
return settings.URL_ROOT + reverse('qm',kwargs={'cave_id':self.found_by.cave.kataster_number,'year':self.found_by.date.year,'qm_id':self.number,'grade':self.grade})
|
||||||
|
|
||||||
def get_next_by_id(self):
|
def get_next_by_id(self):
|
||||||
return QM.objects.get(id=self.id+1)
|
return QM.objects.get(id=self.id+1)
|
||||||
|
@ -57,11 +57,11 @@ def subcave(request, cave_id, subcave):
|
|||||||
subcaveSeq=re.findall('(?:/)([^/]*)',subcave)
|
subcaveSeq=re.findall('(?:/)([^/]*)',subcave)
|
||||||
print subcaveSeq
|
print subcaveSeq
|
||||||
cave=models.Cave.objects.get(kataster_number = cave_id)
|
cave=models.Cave.objects.get(kataster_number = cave_id)
|
||||||
subcave=models.Subcave.objects.get(name=subcaveSeq[0], cave=cave)
|
subcave=models.Subcave.objects.get(title=subcaveSeq[0], cave=cave)
|
||||||
if len(subcaveSeq)>1:
|
if len(subcaveSeq)>1:
|
||||||
for subcaveUrlSegment in subcaveSeq[1:]:
|
for subcaveUrlSegment in subcaveSeq[1:]:
|
||||||
if subcaveUrlSegment:
|
if subcaveUrlSegment:
|
||||||
subcave=subcave.children.get(name=subcaveUrlSegment)
|
subcave=subcave.children.get(title=subcaveUrlSegment)
|
||||||
print subcave
|
print subcave
|
||||||
return render_response(request,'subcave.html', {'subcave': subcave,'cave':cave})
|
return render_response(request,'subcave.html', {'subcave': subcave,'cave':cave})
|
||||||
|
|
||||||
|
@ -263,6 +263,7 @@ div#content {
|
|||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
padding-left: 5em;
|
padding-left: 5em;
|
||||||
padding-right: 5em;
|
padding-right: 5em;
|
||||||
|
padding-bottom:5em;
|
||||||
background:#CCC;
|
background:#CCC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
{% load wiki_markup %}
|
{% load wiki_markup %}
|
||||||
|
{% load link %}
|
||||||
|
|
||||||
{% block title %} QM: {{qm|wiki_to_html_short}} {% endblock %}
|
{% block title %} QM: {{qm|wiki_to_html_short}} {% endblock %}
|
||||||
|
|
||||||
@ -19,6 +20,17 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
<div id="col2">
|
||||||
|
|
||||||
|
<h2>Related items</h2>
|
||||||
|
|
||||||
|
Parent cave: {{qm.found_by.cave|link}}
|
||||||
|
(todo: add parent survey and parent subcave)
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<h3>Location</h3>
|
<h3>Location</h3>
|
||||||
{{qm.location_description}}
|
{{qm.location_description}}
|
||||||
|
|
||||||
|
@ -1,9 +1,24 @@
|
|||||||
{% extends "cavebase.html" %}
|
{% extends "cavebase.html" %}
|
||||||
{% load wiki_markup %}
|
{% load wiki_markup %}
|
||||||
|
{% load mptt_tags %}
|
||||||
{% block title %} Subcave {{subcave}} {% endblock title %}
|
{% block title %} Subcave {{subcave}} {% endblock title %}
|
||||||
{% block editLink %}<a href={{subcave.get_admin_url}}>Edit subcave {{subcave|wiki_to_html_short}}</a>{% endblock %}
|
{% block editLink %}<a href={{subcave.get_admin_url}}>Edit subcave {{subcave|wiki_to_html_short}}</a>{% endblock %}
|
||||||
|
|
||||||
|
{% block contentheader %}
|
||||||
|
{{subcave.title}}
|
||||||
|
{% endblock contentheader %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
ok here comes the drilldown<br />
|
||||||
|
{% drilldown_tree_for_node subcave as drilldown %}
|
||||||
|
{% for each in drilldown %}
|
||||||
|
{{ each }}>
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
<h2>{{subcave}}</h2>
|
<h2>{{subcave}}</h2>
|
||||||
<p>
|
<p>
|
||||||
{{subcave.description}}
|
{{subcave.description}}
|
||||||
|
Loading…
Reference in New Issue
Block a user