mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
n_delete=... soon to be required
This commit is contained in:
parent
55dd577275
commit
ee92182163
@ -5,7 +5,7 @@ import logging
|
|||||||
import re
|
import re
|
||||||
from subprocess import call
|
from subprocess import call
|
||||||
|
|
||||||
import urllib.parse
|
from urllib.parse import urljoin
|
||||||
from decimal import Decimal, getcontext
|
from decimal import Decimal, getcontext
|
||||||
getcontext().prec=2 #use 2 significant figures for decimal calculations
|
getcontext().prec=2 #use 2 significant figures for decimal calculations
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class TroggleModel(models.Model):
|
|||||||
return self._meta.object_name
|
return self._meta.object_name
|
||||||
|
|
||||||
def get_admin_url(self):
|
def get_admin_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT, "/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
|
return urljoin(settings.URL_ROOT, "/admin/core/" + self.object_name().lower() + "/" + str(self.pk))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
abstract = True
|
abstract = True
|
||||||
@ -84,7 +84,7 @@ class Expedition(TroggleModel):
|
|||||||
get_latest_by = 'year'
|
get_latest_by = 'year'
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT, reverse('expedition', args=[self.year]))
|
return urljoin(settings.URL_ROOT, reverse('expedition', args=[self.year]))
|
||||||
|
|
||||||
# construction function. should be moved out
|
# construction function. should be moved out
|
||||||
def get_expedition_day(self, date):
|
def get_expedition_day(self, date):
|
||||||
@ -105,7 +105,7 @@ class Expedition(TroggleModel):
|
|||||||
return res and res[len(res) - 1] or None
|
return res and res[len(res) - 1] or None
|
||||||
|
|
||||||
class ExpeditionDay(TroggleModel):
|
class ExpeditionDay(TroggleModel):
|
||||||
expedition = models.ForeignKey("Expedition")
|
expedition = models.ForeignKey("Expedition",on_delete=models.CASCADE)
|
||||||
date = models.DateField()
|
date = models.DateField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -127,9 +127,9 @@ class Person(TroggleModel):
|
|||||||
|
|
||||||
#href = models.CharField(max_length=200)
|
#href = models.CharField(max_length=200)
|
||||||
orderref = models.CharField(max_length=200) # for alphabetic
|
orderref = models.CharField(max_length=200) # for alphabetic
|
||||||
user = models.OneToOneField(User, null=True, blank=True)
|
user = models.OneToOneField(User, null=True, blank=True,on_delete=models.CASCADE)
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name}))
|
return urljoin(settings.URL_ROOT,reverse('person',kwargs={'first_name':self.first_name,'last_name':self.last_name}))
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name_plural = "People"
|
verbose_name_plural = "People"
|
||||||
@ -168,9 +168,9 @@ class Person(TroggleModel):
|
|||||||
class PersonExpedition(TroggleModel):
|
class PersonExpedition(TroggleModel):
|
||||||
"""Person's attendance to one Expo
|
"""Person's attendance to one Expo
|
||||||
"""
|
"""
|
||||||
expedition = models.ForeignKey(Expedition)
|
expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
|
||||||
person = models.ForeignKey(Person)
|
person = models.ForeignKey(Person,on_delete=models.CASCADE)
|
||||||
slugfield = models.SlugField(max_length=50,blank=True,null=True)
|
slugfield = models.SlugField(max_length=50,blank=True, null=True)
|
||||||
|
|
||||||
is_guest = models.BooleanField(default=False)
|
is_guest = models.BooleanField(default=False)
|
||||||
COMMITTEE_CHOICES = (
|
COMMITTEE_CHOICES = (
|
||||||
@ -181,7 +181,7 @@ class PersonExpedition(TroggleModel):
|
|||||||
('research','Expo research coordinator'),
|
('research','Expo research coordinator'),
|
||||||
)
|
)
|
||||||
expo_committee_position = models.CharField(blank=True,null=True,choices=COMMITTEE_CHOICES,max_length=200)
|
expo_committee_position = models.CharField(blank=True,null=True,choices=COMMITTEE_CHOICES,max_length=200)
|
||||||
nickname = models.CharField(max_length=100,blank=True,null=True)
|
nickname = models.CharField(max_length=100,blank=True, null=True)
|
||||||
|
|
||||||
def GetPersonroles(self):
|
def GetPersonroles(self):
|
||||||
res = [ ]
|
res = [ ]
|
||||||
@ -208,7 +208,7 @@ class PersonExpedition(TroggleModel):
|
|||||||
return self.person.first_name
|
return self.person.first_name
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT, reverse('personexpedition',kwargs={'first_name':self.person.first_name,'last_name':self.person.last_name,'year':self.expedition.year}))
|
return urljoin(settings.URL_ROOT, reverse('personexpedition',kwargs={'first_name':self.person.first_name,'last_name':self.person.last_name,'year':self.expedition.year}))
|
||||||
|
|
||||||
def surveyedleglength(self):
|
def surveyedleglength(self):
|
||||||
survexblocks = [personrole.survexblock for personrole in self.personrole_set.all() ]
|
survexblocks = [personrole.survexblock for personrole in self.personrole_set.all() ]
|
||||||
|
@ -25,7 +25,7 @@ class Area(TroggleModel):
|
|||||||
short_name = models.CharField(max_length=100)
|
short_name = models.CharField(max_length=100)
|
||||||
name = models.CharField(max_length=200, blank=True, null=True)
|
name = models.CharField(max_length=200, blank=True, null=True)
|
||||||
description = models.TextField(blank=True,null=True)
|
description = models.TextField(blank=True,null=True)
|
||||||
parent = models.ForeignKey('Area', blank=True, null=True)
|
parent = models.ForeignKey('Area', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.parent:
|
if self.parent:
|
||||||
return str(self.parent) + " - " + str(self.short_name)
|
return str(self.parent) + " - " + str(self.short_name)
|
||||||
@ -38,14 +38,14 @@ class Area(TroggleModel):
|
|||||||
return self.parent.kat_area()
|
return self.parent.kat_area()
|
||||||
|
|
||||||
class CaveAndEntrance(models.Model):
|
class CaveAndEntrance(models.Model):
|
||||||
cave = models.ForeignKey('Cave')
|
cave = models.ForeignKey('Cave',on_delete=models.CASCADE)
|
||||||
entrance = models.ForeignKey('Entrance')
|
entrance = models.ForeignKey('Entrance',on_delete=models.CASCADE)
|
||||||
entrance_letter = models.CharField(max_length=20,blank=True,null=True)
|
entrance_letter = models.CharField(max_length=20,blank=True, null=True)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.cave) + str(self.entrance_letter)
|
return str(self.cave) + str(self.entrance_letter)
|
||||||
|
|
||||||
class CaveSlug(models.Model):
|
class CaveSlug(models.Model):
|
||||||
cave = models.ForeignKey('Cave')
|
cave = models.ForeignKey('Cave',on_delete=models.CASCADE)
|
||||||
slug = models.SlugField(max_length=50, unique = True)
|
slug = models.SlugField(max_length=50, unique = True)
|
||||||
primary = models.BooleanField(default=False)
|
primary = models.BooleanField(default=False)
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ class Cave(TroggleModel):
|
|||||||
# too much here perhaps,
|
# too much here perhaps,
|
||||||
official_name = models.CharField(max_length=160)
|
official_name = models.CharField(max_length=160)
|
||||||
area = models.ManyToManyField(Area, blank=True)
|
area = models.ManyToManyField(Area, blank=True)
|
||||||
kataster_code = models.CharField(max_length=20,blank=True,null=True)
|
kataster_code = models.CharField(max_length=20,blank=True, null=True)
|
||||||
kataster_number = models.CharField(max_length=10,blank=True, null=True)
|
kataster_number = models.CharField(max_length=10,blank=True, null=True)
|
||||||
unofficial_number = models.CharField(max_length=60,blank=True, null=True)
|
unofficial_number = models.CharField(max_length=60,blank=True, null=True)
|
||||||
entrances = models.ManyToManyField('Entrance', through='CaveAndEntrance')
|
entrances = models.ManyToManyField('Entrance', through='CaveAndEntrance')
|
||||||
@ -65,12 +65,12 @@ class Cave(TroggleModel):
|
|||||||
kataster_status = models.TextField(blank=True,null=True)
|
kataster_status = models.TextField(blank=True,null=True)
|
||||||
underground_centre_line = models.TextField(blank=True,null=True)
|
underground_centre_line = models.TextField(blank=True,null=True)
|
||||||
notes = models.TextField(blank=True,null=True)
|
notes = models.TextField(blank=True,null=True)
|
||||||
length = models.CharField(max_length=100,blank=True,null=True)
|
length = models.CharField(max_length=100,blank=True, null=True)
|
||||||
depth = models.CharField(max_length=100,blank=True,null=True)
|
depth = models.CharField(max_length=100,blank=True, null=True)
|
||||||
extent = models.CharField(max_length=100,blank=True,null=True)
|
extent = models.CharField(max_length=100,blank=True, null=True)
|
||||||
survex_file = models.CharField(max_length=100,blank=True,null=True)
|
survex_file = models.CharField(max_length=100,blank=True, null=True)
|
||||||
description_file = models.CharField(max_length=200,blank=True,null=True)
|
description_file = models.CharField(max_length=200,blank=True, null=True)
|
||||||
url = models.CharField(max_length=200,blank=True,null=True)
|
url = models.CharField(max_length=200,blank=True, null=True)
|
||||||
filename = models.CharField(max_length=200)
|
filename = models.CharField(max_length=200)
|
||||||
|
|
||||||
#class Meta:
|
#class Meta:
|
||||||
@ -215,12 +215,12 @@ def getCaveByReference(reference):
|
|||||||
|
|
||||||
class OtherCaveName(TroggleModel):
|
class OtherCaveName(TroggleModel):
|
||||||
name = models.CharField(max_length=160)
|
name = models.CharField(max_length=160)
|
||||||
cave = models.ForeignKey(Cave)
|
cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.name)
|
return str(self.name)
|
||||||
|
|
||||||
class EntranceSlug(models.Model):
|
class EntranceSlug(models.Model):
|
||||||
entrance = models.ForeignKey('Entrance')
|
entrance = models.ForeignKey('Entrance',on_delete=models.CASCADE)
|
||||||
slug = models.SlugField(max_length=50, unique = True)
|
slug = models.SlugField(max_length=50, unique = True)
|
||||||
primary = models.BooleanField(default=False)
|
primary = models.BooleanField(default=False)
|
||||||
|
|
||||||
@ -260,9 +260,9 @@ class Entrance(TroggleModel):
|
|||||||
other_station = models.TextField(blank=True, null=True)
|
other_station = models.TextField(blank=True, null=True)
|
||||||
other_description = models.TextField(blank=True,null=True)
|
other_description = models.TextField(blank=True,null=True)
|
||||||
bearings = models.TextField(blank=True,null=True)
|
bearings = models.TextField(blank=True,null=True)
|
||||||
url = models.CharField(max_length=200,blank=True,null=True)
|
url = models.CharField(max_length=200,blank=True, null=True)
|
||||||
filename = models.CharField(max_length=200)
|
filename = models.CharField(max_length=200)
|
||||||
cached_primary_slug = models.CharField(max_length=200,blank=True,null=True)
|
cached_primary_slug = models.CharField(max_length=200,blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.slug())
|
return str(self.slug())
|
||||||
@ -415,11 +415,11 @@ class LogbookEntry(TroggleModel):
|
|||||||
)
|
)
|
||||||
|
|
||||||
date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld()
|
date = models.DateField()#MJG wants to turn this into a datetime such that multiple Logbook entries on the same day can be ordered.ld()
|
||||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True)#MJG wants to KILL THIS (redundant information)
|
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS (redundant information)
|
||||||
expedition = models.ForeignKey(Expedition,blank=True,null=True) # yes this is double-
|
expedition = models.ForeignKey(Expedition,blank=True, null=True,on_delete=models.CASCADE) # yes this is double-
|
||||||
title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH)
|
title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH)
|
||||||
cave_slug = models.SlugField(max_length=50)
|
cave_slug = models.SlugField(max_length=50)
|
||||||
place = models.CharField(max_length=100,blank=True,null=True,help_text="Only use this if you haven't chosen a cave")
|
place = models.CharField(max_length=100,blank=True, null=True,help_text="Only use this if you haven't chosen a cave")
|
||||||
text = models.TextField()
|
text = models.TextField()
|
||||||
slug = models.SlugField(max_length=50)
|
slug = models.SlugField(max_length=50)
|
||||||
filename = models.CharField(max_length=200,null=True)
|
filename = models.CharField(max_length=200,null=True)
|
||||||
@ -488,10 +488,10 @@ class LogbookEntry(TroggleModel):
|
|||||||
class QM(TroggleModel):
|
class QM(TroggleModel):
|
||||||
#based on qm.csv in trunk/expoweb/1623/204 which has the fields:
|
#based on qm.csv in trunk/expoweb/1623/204 which has the fields:
|
||||||
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
#"Number","Grade","Area","Description","Page reference","Nearest station","Completion description","Comment"
|
||||||
found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True )
|
found_by = models.ForeignKey(LogbookEntry, related_name='QMs_found',blank=True, null=True,on_delete=models.CASCADE )
|
||||||
ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',null=True,blank=True)
|
ticked_off_by = models.ForeignKey(LogbookEntry, related_name='QMs_ticked_off',blank=True, null=True,on_delete=models.CASCADE)
|
||||||
#cave = models.ForeignKey(Cave)
|
#cave = models.ForeignKey(Cave,on_delete=models.CASCADE)
|
||||||
#expedition = models.ForeignKey(Expedition)
|
#expedition = models.ForeignKey(Expedition,on_delete=models.CASCADE)
|
||||||
|
|
||||||
number = models.IntegerField(help_text="this is the sequential number in the year", )
|
number = models.IntegerField(help_text="this is the sequential number in the year", )
|
||||||
GRADE_CHOICES=(
|
GRADE_CHOICES=(
|
||||||
@ -503,10 +503,10 @@ class QM(TroggleModel):
|
|||||||
)
|
)
|
||||||
grade = models.CharField(max_length=1, choices=GRADE_CHOICES)
|
grade = models.CharField(max_length=1, choices=GRADE_CHOICES)
|
||||||
location_description = models.TextField(blank=True)
|
location_description = models.TextField(blank=True)
|
||||||
nearest_station_description = models.CharField(max_length=400,null=True,blank=True)
|
nearest_station_description = models.CharField(max_length=400,blank=True, null=True)
|
||||||
nearest_station_name = models.CharField(max_length=200,blank=True,null=True)
|
nearest_station_name = models.CharField(max_length=200,blank=True, null=True)
|
||||||
nearest_station = models.ForeignKey(SurvexStation,null=True,blank=True)
|
nearest_station = models.ForeignKey(SurvexStation,blank=True, null=True,on_delete=models.CASCADE)
|
||||||
area = models.CharField(max_length=100,blank=True,null=True)
|
area = models.CharField(max_length=100,blank=True, null=True)
|
||||||
completion_description = models.TextField(blank=True,null=True)
|
completion_description = models.TextField(blank=True,null=True)
|
||||||
comment=models.TextField(blank=True,null=True)
|
comment=models.TextField(blank=True,null=True)
|
||||||
|
|
||||||
@ -541,18 +541,20 @@ def get_scan_path(instance, filename):
|
|||||||
# Single Person going on a trip, which may or may not be written up (accounts for different T/U for people in same logbook entry)
|
# Single Person going on a trip, which may or may not be written up (accounts for different T/U for people in same logbook entry)
|
||||||
#
|
#
|
||||||
class PersonTrip(TroggleModel):
|
class PersonTrip(TroggleModel):
|
||||||
personexpedition = models.ForeignKey("PersonExpedition",null=True)
|
personexpedition = models.ForeignKey("PersonExpedition",null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
#expeditionday = models.ForeignKey("ExpeditionDay")#MJG wants to KILL THIS (redundant information)
|
#expeditionday = models.ForeignKey("ExpeditionDay",on_delete=models.CASCADE)#MJG wants to KILL THIS (redundant information)
|
||||||
#date = models.DateField() #MJG wants to KILL THIS (redundant information)
|
#date = models.DateField() #MJG wants to KILL THIS (redundant information)
|
||||||
time_underground = models.FloatField(help_text="In decimal hours")
|
time_underground = models.FloatField(help_text="In decimal hours")
|
||||||
logbook_entry = models.ForeignKey(LogbookEntry)
|
logbook_entry = models.ForeignKey(LogbookEntry,on_delete=models.CASCADE)
|
||||||
is_logbook_entry_author = models.BooleanField(default=False)
|
is_logbook_entry_author = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
||||||
# sequencing by person (difficult to solve locally)
|
# sequencing by person (difficult to solve locally)
|
||||||
#persontrip_next = models.ForeignKey('PersonTrip', related_name='pnext', blank=True,null=True)#MJG wants to KILL THIS (and use funstion persontrip_next_auto)
|
#persontrip_next = models.ForeignKey('PersonTrip', related_name='pnext',
|
||||||
#persontrip_prev = models.ForeignKey('PersonTrip', related_name='pprev', blank=True,null=True)#MJG wants to KILL THIS(and use funstion persontrip_prev_auto)
|
#blank=True,null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS (and use funstion persontrip_next_auto)
|
||||||
|
#persontrip_prev = models.ForeignKey('PersonTrip', related_name='pprev',
|
||||||
|
#blank=True,null=True,on_delete=models.CASCADE)#MJG wants to KILL THIS(and use funstion persontrip_prev_auto)
|
||||||
|
|
||||||
def persontrip_next(self):
|
def persontrip_next(self):
|
||||||
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
|
futurePTs = PersonTrip.objects.filter(personexpedition = self.personexpedition, logbook_entry__date__gt = self.logbook_entry.date).order_by('logbook_entry__date').all()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import urllib.parse
|
from urllib.parse import urljoin
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
@ -16,8 +16,8 @@ from django.core.urlresolvers import reverse
|
|||||||
|
|
||||||
class SurvexDirectory(models.Model):
|
class SurvexDirectory(models.Model):
|
||||||
path = models.CharField(max_length=200)
|
path = models.CharField(max_length=200)
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True)
|
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
primarysurvexfile = models.ForeignKey('SurvexFile', related_name='primarysurvexfile', blank=True, null=True)
|
primarysurvexfile = models.ForeignKey('SurvexFile', related_name='primarysurvexfile', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
# could also include files in directory but not referenced
|
# could also include files in directory but not referenced
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -26,8 +26,8 @@ class SurvexDirectory(models.Model):
|
|||||||
|
|
||||||
class SurvexFile(models.Model):
|
class SurvexFile(models.Model):
|
||||||
path = models.CharField(max_length=200)
|
path = models.CharField(max_length=200)
|
||||||
survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True)
|
survexdirectory = models.ForeignKey("SurvexDirectory", blank=True, null=True,on_delete=models.CASCADE)
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True)
|
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('id',)
|
ordering = ('id',)
|
||||||
@ -53,7 +53,7 @@ class SurvexFile(models.Model):
|
|||||||
|
|
||||||
|
|
||||||
class SurvexEquate(models.Model):
|
class SurvexEquate(models.Model):
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True)
|
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
class SurvexStationLookUpManager(models.Manager):
|
class SurvexStationLookUpManager(models.Manager):
|
||||||
def lookup(self, name):
|
def lookup(self, name):
|
||||||
@ -63,8 +63,8 @@ class SurvexStationLookUpManager(models.Manager):
|
|||||||
|
|
||||||
class SurvexStation(models.Model):
|
class SurvexStation(models.Model):
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
block = models.ForeignKey('SurvexBlock')
|
block = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
|
||||||
equate = models.ForeignKey('SurvexEquate', blank=True, null=True)
|
equate = models.ForeignKey('SurvexEquate', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
objects = SurvexStationLookUpManager()
|
objects = SurvexStationLookUpManager()
|
||||||
x = models.FloatField(blank=True, null=True)
|
x = models.FloatField(blank=True, null=True)
|
||||||
y = models.FloatField(blank=True, null=True)
|
y = models.FloatField(blank=True, null=True)
|
||||||
@ -82,10 +82,10 @@ class SurvexStation(models.Model):
|
|||||||
return r
|
return r
|
||||||
|
|
||||||
# class SurvexLeg(models.Model):
|
# class SurvexLeg(models.Model):
|
||||||
# block = models.ForeignKey('SurvexBlock')
|
# block = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
|
||||||
# #title = models.ForeignKey('SurvexTitle')
|
# #title = models.ForeignKey('SurvexTitle',on_delete=models.CASCADE)
|
||||||
# stationfrom = models.ForeignKey('SurvexStation', related_name='stationfrom')
|
# stationfrom = models.ForeignKey('SurvexStation', related_name='stationfrom',on_delete=models.CASCADE)
|
||||||
# stationto = models.ForeignKey('SurvexStation', related_name='stationto')
|
# stationto = models.ForeignKey('SurvexStation', related_name='stationto',on_delete=models.CASCADE)
|
||||||
# tape = models.FloatField()
|
# tape = models.FloatField()
|
||||||
# compass = models.FloatField()
|
# compass = models.FloatField()
|
||||||
# clino = models.FloatField()
|
# clino = models.FloatField()
|
||||||
@ -111,25 +111,25 @@ class SurvexBlockLookUpManager(models.Manager):
|
|||||||
class SurvexBlock(models.Model):
|
class SurvexBlock(models.Model):
|
||||||
objects = SurvexBlockLookUpManager()
|
objects = SurvexBlockLookUpManager()
|
||||||
name = models.CharField(max_length=100)
|
name = models.CharField(max_length=100)
|
||||||
parent = models.ForeignKey('SurvexBlock', blank=True, null=True)
|
parent = models.ForeignKey('SurvexBlock', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
# text = models.TextField()
|
# text = models.TextField()
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True)
|
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
date = models.DateField(blank=True, null=True)
|
date = models.DateField(blank=True, null=True)
|
||||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True)
|
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.CASCADE)
|
||||||
expedition = models.ForeignKey('Expedition', blank=True, null=True)
|
expedition = models.ForeignKey('Expedition', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
survexfile = models.ForeignKey("SurvexFile", blank=True, null=True)
|
survexfile = models.ForeignKey("SurvexFile", blank=True, null=True,on_delete=models.CASCADE)
|
||||||
# begin_char = models.IntegerField() # code for where in the survex data files this block sits
|
# begin_char = models.IntegerField() # code for where in the survex data files this block sits
|
||||||
survexpath = models.CharField(max_length=200) # the path for the survex stations
|
survexpath = models.CharField(max_length=200) # the path for the survex stations
|
||||||
|
|
||||||
survexscansfolder = models.ForeignKey("SurvexScansFolder", null=True)
|
survexscansfolder = models.ForeignKey("SurvexScansFolder", null=True,on_delete=models.CASCADE)
|
||||||
#refscandir = models.CharField(max_length=100)
|
#refscandir = models.CharField(max_length=100)
|
||||||
|
|
||||||
legsall = models.IntegerField() # summary data for this block
|
legsall = models.IntegerField(null=True) # summary data for this block
|
||||||
legssplay = models.IntegerField() # summary data for this block
|
legssplay = models.IntegerField(null=True) # summary data for this block
|
||||||
legssurfc = models.IntegerField() # summary data for this block
|
legssurfc = models.IntegerField(null=True) # summary data for this block
|
||||||
totalleglength = models.FloatField()
|
totalleglength = models.FloatField(null=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('id',)
|
ordering = ('id',)
|
||||||
@ -163,9 +163,9 @@ class SurvexBlock(models.Model):
|
|||||||
return list(self.expeditionday.survexblock_set.all()).index(self)
|
return list(self.expeditionday.survexblock_set.all()).index(self)
|
||||||
|
|
||||||
class SurvexTitle(models.Model):
|
class SurvexTitle(models.Model):
|
||||||
survexblock = models.ForeignKey('SurvexBlock')
|
survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
|
||||||
title = models.CharField(max_length=200)
|
title = models.CharField(max_length=200)
|
||||||
cave = models.ForeignKey('Cave', blank=True, null=True)
|
cave = models.ForeignKey('Cave', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
#
|
#
|
||||||
# member of a SurvexBlock
|
# member of a SurvexBlock
|
||||||
@ -183,14 +183,14 @@ ROLE_CHOICES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
class SurvexPersonRole(models.Model):
|
class SurvexPersonRole(models.Model):
|
||||||
survexblock = models.ForeignKey('SurvexBlock')
|
survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
|
||||||
nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True)
|
nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True)
|
||||||
# increasing levels of precision
|
# increasing levels of precision
|
||||||
personname = models.CharField(max_length=100)
|
personname = models.CharField(max_length=100)
|
||||||
person = models.ForeignKey('Person', blank=True, null=True)
|
person = models.ForeignKey('Person', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
personexpedition = models.ForeignKey('PersonExpedition', blank=True, null=True)
|
personexpedition = models.ForeignKey('PersonExpedition', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
persontrip = models.ForeignKey('PersonTrip', blank=True, null=True)
|
persontrip = models.ForeignKey('PersonTrip', blank=True, null=True,on_delete=models.CASCADE)
|
||||||
expeditionday = models.ForeignKey("ExpeditionDay", null=True)
|
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.person) + " - " + str(self.survexblock) + " - " + str(self.nrole)
|
return str(self.person) + " - " + str(self.survexblock) + " - " + str(self.nrole)
|
||||||
@ -203,7 +203,7 @@ class SurvexScansFolder(models.Model):
|
|||||||
ordering = ('walletname',)
|
ordering = ('walletname',)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT, reverse('surveyscansfolder', kwargs={"path":re.sub("#", "%23", self.walletname)}))
|
return urljoin(settings.URL_ROOT, reverse('surveyscansfolder', kwargs={"path":re.sub("#", "%23", self.walletname)}))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return str(self.walletname) + " (Survey Scans Folder)"
|
return str(self.walletname) + " (Survey Scans Folder)"
|
||||||
@ -211,13 +211,13 @@ class SurvexScansFolder(models.Model):
|
|||||||
class SurvexScanSingle(models.Model):
|
class SurvexScanSingle(models.Model):
|
||||||
ffile = models.CharField(max_length=200)
|
ffile = models.CharField(max_length=200)
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
survexscansfolder = models.ForeignKey("SurvexScansFolder", null=True)
|
survexscansfolder = models.ForeignKey("SurvexScansFolder", null=True,on_delete=models.CASCADE)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ('name',)
|
ordering = ('name',)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return urllib.parse.urljoin(settings.URL_ROOT, reverse('surveyscansingle', kwargs={"path":re.sub("#", "%23", self.survexscansfolder.walletname), "file":self.name}))
|
return urljoin(settings.URL_ROOT, reverse('surveyscansingle', kwargs={"path":re.sub("#", "%23", self.survexscansfolder.walletname), "file":self.name}))
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Survey Scan Image: " + str(self.name) + " in " + str(self.survexscansfolder)
|
return "Survey Scan Image: " + str(self.name) + " in " + str(self.survexscansfolder)
|
||||||
|
@ -7,6 +7,6 @@ class Redirect(models.Model):
|
|||||||
|
|
||||||
class EntranceRedirect(models.Model):
|
class EntranceRedirect(models.Model):
|
||||||
originalURL = models.CharField(max_length=200)
|
originalURL = models.CharField(max_length=200)
|
||||||
entrance = models.ForeignKey(Entrance)
|
entrance = models.ForeignKey(Entrance,on_delete=models.CASCADE)
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.entrance.slug
|
return self.entrance.slug
|
||||||
|
Loading…
Reference in New Issue
Block a user