[svn] Remove old subcave model, along with mptt and feincms. Also move OtherCaveNames admin representation to an inline in Cave.

This commit is contained in:
substantialnoninfringinguser
2009-07-04 19:26:51 +01:00
parent 4f0271ad49
commit 38a545e174
45 changed files with 9 additions and 1930 deletions

View File

@@ -1,6 +1,5 @@
from troggle.core.models import *
from django.contrib import admin
from feincms.admin import editor
from django.forms import ModelForm
import django.forms as forms
from core.forms import LogbookEntryForm
@@ -31,6 +30,10 @@ class ScannedImageInline(admin.TabularInline):
model = ScannedImage
extra = 4
class OtherCaveInline(admin.TabularInline):
model = OtherCaveName
extra = 1
class SurveyAdmin(TroggleModelAdmin):
inlines = (ScannedImageInline,)
search_fields = ('expedition__year','wallet_number')
@@ -90,17 +93,13 @@ class PersonExpeditionAdmin(TroggleModelAdmin):
class CaveAdmin(TroggleModelAdmin):
search_fields = ('official_name','kataster_number','unofficial_number')
#inlines = (QMInline,)
inlines = (OtherCaveInline,)
extra = 4
class SubcaveAdmin(editor.TreeEditorMixin,TroggleModelAdmin):
pass
admin.site.register(Photo)
admin.site.register(Subcave, SubcaveAdmin)
admin.site.register(Cave, CaveAdmin)
admin.site.register(Area)
admin.site.register(OtherCaveName)
#admin.site.register(OtherCaveName)
admin.site.register(CaveAndEntrance)
admin.site.register(SurveyStation)
admin.site.register(NewSubCave)
@@ -131,9 +130,4 @@ def export_as_xml(modeladmin, request, queryset):
return response
admin.site.add_action(export_as_xml)
admin.site.add_action(export_as_json)
try:
mptt.register(Subcave, order_insertion_by=['name'])
except mptt.AlreadyRegistered:
print "mptt already registered"
admin.site.add_action(export_as_json)

View File

@@ -1,10 +1,4 @@
import urllib, urlparse, string, os, datetime, logging
try:
import mptt
except ImportError:
#I think we should be having troggle directory as the base import place
#but I am leaving the following line in to make sure I do not break anything
import troggle.mptt as mptt
from django.forms import ModelForm
from django.db import models
from django.contrib import admin
@@ -502,15 +496,6 @@ class Entrance(TroggleModel):
if f[0] == self.findability:
return f[1]
class Subcave(TroggleModel):
description = models.TextField(blank=True, null=True)
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!")
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
#adjoining = models.ManyToManyField('Subcave',blank=True, null=True,)
legacy_description_path = models.CharField(max_length=600, blank=True, null=True)
def __unicode__(self):
return self.title
def get_absolute_url(self):
@@ -522,28 +507,6 @@ class Subcave(TroggleModel):
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):
# urlString=self.name
# if self.parent:
# parent=self.parent
# while parent: #recursively walk up the tree, adding parents to the left of the URL
# urlString=parent.name+'/'+urlString
# if parent.cave:
# cave=parent.cave
# parent=parent.parent
# urlString='cave/'+unicode(cave.kataster_number)+'/'+urlString
# else:
# urlString='cave/'+unicode(self.cave.kataster_number)+'/'+urlString
# return urlparse.urljoin(settings.URL_ROOT, urlString)
try:
mptt.register(Subcave, order_insertion_by=['title'])
except mptt.AlreadyRegistered:
print "mptt already registered"
class CaveDescription(TroggleModel):
short_name = models.CharField(max_length=50, unique = True)
@@ -666,7 +629,7 @@ class Survey(TroggleModel):
wallet_letter = models.CharField(max_length=1,blank=True,null=True)
comments = models.TextField(blank=True,null=True)
location = models.CharField(max_length=400,blank=True,null=True) #REDUNDANT
subcave = models.ForeignKey('Subcave', blank=True, null=True)
subcave = models.ForeignKey('NewSubCave', blank=True, null=True)
#notes_scan = models.ForeignKey('ScannedImage',related_name='notes_scan',blank=True, null=True) #Replaced by contents field of ScannedImage model
survex_block = models.OneToOneField('SurvexBlock',blank=True, null=True)
logbook_entry = models.ForeignKey('LogbookEntry')

View File

@@ -56,19 +56,6 @@ def survexblock(request, survexpath):
ftext = survexblock.text
return render_with_context(request,'survexblock.html', {'survexblock':survexblock, 'ftext':ftext, })
def subcave(request, cave_id, subcave):
print subcave
subcaveSeq=re.findall('(?:/)([^/]*)',subcave)
print subcaveSeq
cave=models.Cave.objects.get(kataster_number = cave_id)
subcave=models.Subcave.objects.get(title=subcaveSeq[0], cave=cave)
if len(subcaveSeq)>1:
for subcaveUrlSegment in subcaveSeq[1:]:
if subcaveUrlSegment:
subcave=subcave.children.get(title=subcaveUrlSegment)
print subcave
return render_with_context(request,'subcave.html', {'subcave': subcave,'cave':cave})
def surveyindex(request):
surveys=Survey.objects.all()
expeditions=Expedition.objects.order_by("-year")