forked from expo/troggle
Clean up indenting in models
add registration required modules
This commit is contained in:
parent
e6b12e99e6
commit
1974d0758a
@ -264,13 +264,13 @@ class LogbookEntry(TroggleModel):
|
|||||||
if item == "cave": #Allow a logbookentries cave to be directly accessed despite not having a proper foreignkey
|
if item == "cave": #Allow a logbookentries cave to be directly accessed despite not having a proper foreignkey
|
||||||
return CaveSlug.objects.get(slug = self.cave_slug).cave
|
return CaveSlug.objects.get(slug = self.cave_slug).cave
|
||||||
return super(LogbookEntry, self).__getattribute__(item)
|
return super(LogbookEntry, self).__getattribute__(item)
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
if "cave" in kwargs.keys():
|
if "cave" in kwargs.keys():
|
||||||
if kwargs["cave"] is not None:
|
if kwargs["cave"] is not None:
|
||||||
kwargs["cave_slug"] = CaveSlug.objects.get(cave = kwargs["cave"], primary = True).slug
|
kwargs["cave_slug"] = CaveSlug.objects.get(cave=kwargs["cave"], primary=True).slug
|
||||||
kwargs.pop("cave")
|
kwargs.pop("cave")
|
||||||
return super(LogbookEntry, self).__init__(*args, **kwargs)
|
return super(LogbookEntry, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def isLogbookEntry(self): # Function used in templates
|
def isLogbookEntry(self): # Function used in templates
|
||||||
return True
|
return True
|
||||||
@ -520,11 +520,11 @@ class Cave(TroggleModel):
|
|||||||
areas = self.area.all()
|
areas = self.area.all()
|
||||||
lowestareas = list(areas)
|
lowestareas = list(areas)
|
||||||
for area in areas:
|
for area in areas:
|
||||||
if area.parent in areas:
|
if area.parent in areas:
|
||||||
try:
|
try:
|
||||||
lowestareas.remove(area.parent)
|
lowestareas.remove(area.parent)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
return lowestareas[0]
|
return lowestareas[0]
|
||||||
|
|
||||||
def getCaveByReference(reference):
|
def getCaveByReference(reference):
|
||||||
@ -608,21 +608,21 @@ class Entrance(TroggleModel):
|
|||||||
s = SurvexStation.objects.lookup(self.tag_station)
|
s = SurvexStation.objects.lookup(self.tag_station)
|
||||||
return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
|
return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
|
||||||
except:
|
except:
|
||||||
return r + "%s Tag Station not in dataset" % self.tag_station
|
return r + "%s Tag Station not in dataset" % self.tag_station
|
||||||
if self.exact_station:
|
if self.exact_station:
|
||||||
try:
|
try:
|
||||||
s = SurvexStation.objects.lookup(self.exact_station)
|
s = SurvexStation.objects.lookup(self.exact_station)
|
||||||
return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
|
return r + "%0.0fE %0.0fN %0.0fAlt" % (s.x, s.y, s.z)
|
||||||
except:
|
except:
|
||||||
return r + "%s Exact Station not in dataset" % self.tag_station
|
return r + "%s Exact Station not in dataset" % self.tag_station
|
||||||
if self.other_station:
|
if self.other_station:
|
||||||
try:
|
try:
|
||||||
s = SurvexStation.objects.lookup(self.other_station)
|
s = SurvexStation.objects.lookup(self.other_station)
|
||||||
return r + "%0.0fE %0.0fN %0.0fAlt %s" % (s.x, s.y, s.z, self.other_description)
|
return r + "%0.0fE %0.0fN %0.0fAlt %s" % (s.x, s.y, s.z, self.other_description)
|
||||||
except:
|
except:
|
||||||
return r + "%s Other Station not in dataset" % self.tag_station
|
return r + "%s Other Station not in dataset" % self.tag_station
|
||||||
if self.FINDABLE_CHOICES == "S":
|
if self.FINDABLE_CHOICES == "S":
|
||||||
r += "ERROR, Entrance has been surveyed but has no survex point"
|
r += "ERROR, Entrance has been surveyed but has no survex point"
|
||||||
if self.bearings:
|
if self.bearings:
|
||||||
return r + self.bearings
|
return r + self.bearings
|
||||||
return r
|
return r
|
||||||
@ -657,7 +657,7 @@ class Entrance(TroggleModel):
|
|||||||
return SurvexStation.objects.lookup(self.tag_station)
|
return SurvexStation.objects.lookup(self.tag_station)
|
||||||
|
|
||||||
def needs_surface_work(self):
|
def needs_surface_work(self):
|
||||||
return self.findability != "S" or not self.has_photo or self.marking != "T"
|
return self.findability != "S" or not self.has_photo or self.marking != "T"
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
|
|
||||||
@ -754,10 +754,10 @@ class QM(TroggleModel):
|
|||||||
comment=models.TextField(blank=True,null=True)
|
comment=models.TextField(blank=True,null=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u"%s %s" % (self.code(), self.grade)
|
return u"%s %s" % (self.code(), self.grade)
|
||||||
|
|
||||||
def code(self):
|
def code(self):
|
||||||
return u"%s-%s-%s" % (unicode(self.found_by.cave)[6:], self.found_by.date.year, self.number)
|
return u"%s-%s-%s" % (unicode(self.found_by.cave)[6:], self.found_by.date.year, self.number)
|
||||||
|
|
||||||
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
|
||||||
@ -770,7 +770,7 @@ class QM(TroggleModel):
|
|||||||
return QM.objects.get(id=self.id-1)
|
return QM.objects.get(id=self.id-1)
|
||||||
|
|
||||||
def wiki_link(self):
|
def wiki_link(self):
|
||||||
return u"%s%s%s" % ('[[QM:',self.code(),']]')
|
return u"%s%s%s" % ('[[QM:',self.code(),']]')
|
||||||
|
|
||||||
photoFileStorage = FileSystemStorage(location=settings.PHOTOS_ROOT, base_url=settings.PHOTOS_URL)
|
photoFileStorage = FileSystemStorage(location=settings.PHOTOS_ROOT, base_url=settings.PHOTOS_URL)
|
||||||
class DPhoto(TroggleImageModel):
|
class DPhoto(TroggleImageModel):
|
||||||
@ -825,7 +825,7 @@ class ScannedImage(TroggleImageModel):
|
|||||||
|
|
||||||
#This is an ugly hack to deal with the #s in our survey scan paths. The correct thing is to write a custom file storage backend which calls urlencode on the name for making file.url but not file.path.
|
#This is an ugly hack to deal with the #s in our survey scan paths. The correct thing is to write a custom file storage backend which calls urlencode on the name for making file.url but not file.path.
|
||||||
def correctURL(self):
|
def correctURL(self):
|
||||||
return string.replace(self.file.url,r'#',r'%23')
|
return string.replace(self.file.url,r'#',r'%23')
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return get_scan_path(self,'')
|
return get_scan_path(self,'')
|
||||||
@ -852,10 +852,10 @@ class Survey(TroggleModel):
|
|||||||
return self.expedition.year+"#"+"%02d" % int(self.wallet_number)
|
return self.expedition.year+"#"+"%02d" % int(self.wallet_number)
|
||||||
|
|
||||||
def notes(self):
|
def notes(self):
|
||||||
return self.scannedimage_set.filter(contents='notes')
|
return self.scannedimage_set.filter(contents='notes')
|
||||||
|
|
||||||
def plans(self):
|
def plans(self):
|
||||||
return self.scannedimage_set.filter(contents='plan')
|
return self.scannedimage_set.filter(contents='plan')
|
||||||
|
|
||||||
def elevations(self):
|
def elevations(self):
|
||||||
return self.scannedimage_set.filter(contents='elevation')
|
return self.scannedimage_set.filter(contents='elevation')
|
||||||
|
@ -75,6 +75,8 @@ MIDDLEWARE_CLASSES = (
|
|||||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
|
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
|
||||||
'django.middleware.csrf.CsrfViewMiddleware',
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'troggle.middleware.SmartAppendSlashMiddleware'
|
'troggle.middleware.SmartAppendSlashMiddleware'
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -91,6 +93,7 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.sites',
|
'django.contrib.sites',
|
||||||
'django.contrib.redirects',
|
'django.contrib.redirects',
|
||||||
|
'django.contrib.messages',
|
||||||
#'troggle.photologue',
|
#'troggle.photologue',
|
||||||
#'troggle.reversion',
|
#'troggle.reversion',
|
||||||
#'django_evolution',
|
#'django_evolution',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user