From 5d8a5494cdb0409501b9182784a046e284d4d7b0 Mon Sep 17 00:00:00 2001
From: Martin Green
Date: Mon, 11 Jul 2011 00:50:07 +0100
Subject: [PATCH] Split up tags such that they use ajax
---
core/views_caves.py | 25 +++++++
templates/cave.html | 93 ++-----------------------
templates/cave_entrances.html | 12 ++++
templates/cave_logbook.html | 12 ++++
templates/cave_qms.html | 20 ++++++
templates/cave_uground_description.html | 36 ++++++++++
urls.py | 8 ++-
7 files changed, 116 insertions(+), 90 deletions(-)
create mode 100644 templates/cave_entrances.html
create mode 100644 templates/cave_logbook.html
create mode 100644 templates/cave_qms.html
create mode 100644 templates/cave_uground_description.html
diff --git a/core/views_caves.py b/core/views_caves.py
index 24a85c7..d078338 100644
--- a/core/views_caves.py
+++ b/core/views_caves.py
@@ -35,6 +35,31 @@ def cave(request, cave_id='', offical_name=''):
else:
return render_with_context(request,'cave.html', {'cave': cave, 'cavepage': True})
+def caveEntrance(request, slug):
+ cave = Cave.objects.get(slug = slug)
+ if cave.non_public and not request.user.is_authenticated():
+ return render_with_context(request,'nonpublic.html', {'instance': cave})
+ else:
+ return render_with_context(request,'cave_entrances.html', {'cave': cave})
+def caveDescription(request, slug):
+ cave = Cave.objects.get(slug = slug)
+ if cave.non_public and not request.user.is_authenticated():
+ return render_with_context(request,'nonpublic.html', {'instance': cave})
+ else:
+ return render_with_context(request,'cave_uground_description.html', {'cave': cave})
+def caveQMs(request, slug):
+ cave = Cave.objects.get(slug = slug)
+ if cave.non_public and not request.user.is_authenticated():
+ return render_with_context(request,'nonpublic.html', {'instance': cave})
+ else:
+ return render_with_context(request,'cave_qms.html', {'cave': cave})
+def caveLogbook(request, slug):
+ cave = Cave.objects.get(slug = slug)
+ if cave.non_public and not request.user.is_authenticated():
+ return render_with_context(request,'nonpublic.html', {'instance': cave})
+ else:
+ return render_with_context(request,'cave_logbook.html', {'cave': cave})
+
def caveSlug(request, slug):
cave = Cave.objects.get(slug = slug)
if cave.non_public and not request.user.is_authenticated():
diff --git a/templates/cave.html b/templates/cave.html
index 12e83b4..d90f10b 100644
--- a/templates/cave.html
+++ b/templates/cave.html
@@ -29,96 +29,13 @@
-
-
{% if cave.entrances %}
-
Entrances
- {% for ent in cave.entrances %}
-
{{ ent.entrance_letter|safe }}
- {% if ent.entrance.marking %}
- Marking: {{ ent.entrance.marking_val|safe }}
- {% endif %}
-
- {% endfor %}
-{% endif %}
-
-
-
{% if cave.explorers %}
-
Explorers
- {{ cave.explorers|safe }}
-{% endif %}
-{% if cave.underground_description %}
-
Underground Description
- {{ cave.underground_description|safe }}
-{% endif %}
-{% if cave.equipment %}
-
Equipment
- {{ cave.equipment|safe }}
-{% endif %}
-{% if cave.references %}
-
References
- {{ cave.references|safe }}
-{% endif %}
-{% if cave.survey %}
-
Survey
- {{ cave.survey|safe }}
-{% endif %}
-{% if cave.kataster_status %}
-
Kataster_status
- {{ cave.kataster_status|safe }}
-{% endif %}
-{% if cave.underground_centre_line %}
-
Underground Centre Line
- {{ cave.underground_centre_line|safe }}
-{% endif %}
-{% if cave.survex_file %}
-
Survex File
- {{ cave.survex_file|safe }}
-{% endif %}
-{% if cave.notes %}
-
Notes
- {{ cave.notes|safe }}
-{% endif %}
-
-
-
-
- {% for logbookentry in cave.logbookentry_set.all %}
- {% if logbookentry.title %}
-
- {{logbookentry.date}} |
- {{logbookentry.title|safe}} |
-
- {% endif %}
- {% endfor %}
-
-
-
-
{% if cave.get_QMs %}
-
Question marks
-
Extant
-
- {% for QM in cave.get_QMs %}
- {% if QM.ticked_off_by %}
- {% else %}
- - {{QM}}
- {% endif %}
- {% endfor %}
-
-
Ticked off
-
- {% for QM in cave.get_QMs %}
- {% if QM.ticked_off_by %}
- - {{QM}}
- {% endif %}
- {% endfor %}
-
-{% endif %}
+
diff --git a/templates/cave_entrances.html b/templates/cave_entrances.html
new file mode 100644
index 0000000..dbd450d
--- /dev/null
+++ b/templates/cave_entrances.html
@@ -0,0 +1,12 @@
+
+
{% if cave.entrances %}
+
Entrances
+ {% for ent in cave.entrances %}
+
{{ ent.entrance_letter|safe }}
+ {% if ent.entrance.marking %}
+ Marking: {{ ent.entrance.marking_val|safe }}
+ {% endif %}
+
+ {% endfor %}
+{% endif %}
+
diff --git a/templates/cave_logbook.html b/templates/cave_logbook.html
new file mode 100644
index 0000000..e2dd8e4
--- /dev/null
+++ b/templates/cave_logbook.html
@@ -0,0 +1,12 @@
+
+
+ {% for logbookentry in cave.logbookentry_set.all %}
+ {% if logbookentry.title %}
+
+ {{logbookentry.date}} |
+ {{logbookentry.title|safe}} |
+
+ {% endif %}
+ {% endfor %}
+
+
diff --git a/templates/cave_qms.html b/templates/cave_qms.html
new file mode 100644
index 0000000..9a7f23a
--- /dev/null
+++ b/templates/cave_qms.html
@@ -0,0 +1,20 @@
+ {% if cave.get_QMs %}
+
Question marks
+ Extant
+
+ {% for QM in cave.get_QMs %}
+ {% if QM.ticked_off_by %}
+ {% else %}
+ - {{QM}}
+ {% endif %}
+ {% endfor %}
+
+ Ticked off
+
+ {% for QM in cave.get_QMs %}
+ {% if QM.ticked_off_by %}
+ - {{QM}}
+ {% endif %}
+ {% endfor %}
+
+{% endif %}
diff --git a/templates/cave_uground_description.html b/templates/cave_uground_description.html
new file mode 100644
index 0000000..66cc62c
--- /dev/null
+++ b/templates/cave_uground_description.html
@@ -0,0 +1,36 @@
+ {% if cave.explorers %}
+
Explorers
+ {{ cave.explorers|safe }}
+{% endif %}
+{% if cave.underground_description %}
+ Underground Description
+ {{ cave.underground_description|safe }}
+{% endif %}
+{% if cave.equipment %}
+ Equipment
+ {{ cave.equipment|safe }}
+{% endif %}
+{% if cave.references %}
+ References
+ {{ cave.references|safe }}
+{% endif %}
+{% if cave.survey %}
+ Survey
+ {{ cave.survey|safe }}
+{% endif %}
+{% if cave.kataster_status %}
+ Kataster_status
+ {{ cave.kataster_status|safe }}
+{% endif %}
+{% if cave.underground_centre_line %}
+ Underground Centre Line
+ {{ cave.underground_centre_line|safe }}
+{% endif %}
+{% if cave.survex_file %}
+ Survex File
+ {{ cave.survex_file|safe }}
+{% endif %}
+{% if cave.notes %}
+ Notes
+ {{ cave.notes|safe }}
+{% endif %}
diff --git a/urls.py b/urls.py
index 24df04b..9bddbfb 100644
--- a/urls.py
+++ b/urls.py
@@ -45,8 +45,12 @@ actualurlpatterns = patterns('',
url(r'^cave/(?P[^/]+)/?$', views_caves.cave, name="cave"),
url(r'^caveslug/([^/]+)/?$', views_caves.caveSlug, name="caveSlug"),
- url(r'^cavedescription/(?P[^/]+)/?$', views_caves.cave_description, name="cavedescription"),
- url(r'^cavedescription/?$', object_list, {'queryset':CaveDescription.objects.all(),'template_name':'object_list.html'}, name="cavedescriptions"),
+ url(r'^cave/entrance/([^/]+)/?$', views_caves.caveEntrance),
+ url(r'^cave/description/([^/]+)/?$', views_caves.caveDescription),
+ url(r'^cave/qms/([^/]+)/?$', views_caves.caveQMs),
+ url(r'^cave/logbook/([^/]+)/?$', views_caves.caveLogbook),
+ #url(r'^cavedescription/(?P[^/]+)/?$', 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'^jgtfile/(.*)$', view_surveys.jgtfile, name="jgtfile"),