dwg upload and django admin extra search

This commit is contained in:
Philip Sargent
2021-05-05 00:35:10 +01:00
parent 44b6770b6a
commit d374779c47
13 changed files with 333 additions and 239 deletions

View File

@@ -432,7 +432,7 @@ class LogbookEntry(TroggleModel):
# #return super(LogbookEntry, self).__init__(*args, **kwargs) # works in py3.5
# #return TroggleModel.__init__(*args, **kwargs) # fails in py3.5, runtime fail in 3.8
def cave(self): # Why didn't he just make this a foreign key to Cave ? Replaces __egtattrribute__ sillyness.
def cave(self): # Why didn't he just make this a foreign key to Cave ? Replaces __getattrribute__ sillyness.
c = CaveSlug.objects.get(slug=self.cave_slug, primary=True).cave
return c
@@ -540,13 +540,13 @@ class PersonTrip(TroggleModel):
def __str__(self):
return f'{self.personexpedition} ({self.logbook_entry.date})'
scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
def get_scan_path(instance, filename):
year=instance.survey.expedition.year
number=str(instance.survey.wallet_number)
if str(instance.survey.wallet_letter) != "None":
number=str(instance.survey.wallet_letter) + number #two strings formatting because convention is 2009#01 or 2009#X01
return os.path.join('./',year,year+r'#'+number,str(instance.contents)+str(instance.number_in_wallet)+r'.jpg')
# scansFileStorage = FileSystemStorage(location=settings.SURVEY_SCANS, base_url=settings.SURVEYS_URL)
# def get_scan_path(instance, filename):
# year=instance.survey.expedition.year
# number=str(instance.survey.wallet_number)
# if str(instance.survey.wallet_letter) != "None":
# number=str(instance.survey.wallet_letter) + number #two strings formatting because convention is 2009#01 or 2009#X01
# return os.path.join('./',year,year+r'#'+number,str(instance.contents)+str(instance.number_in_wallet)+r'.jpg')
Gcavelookup = None
Gcave_count = None

View File

@@ -15,10 +15,10 @@ class SurvexDirectory(models.Model):
class Meta:
ordering = ('id',)
verbose_name_plural = "Survex directories"
# Don't change from the default as that breaks troggle webpages and internal referencing!
# def __str__(self):
# return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]"
def __str__(self):
return "[SurvexDirectory:"+str(self.path) + "-" + str(self.primarysurvexfile.path) + "-" + str(self.cave)+"]"
class SurvexFile(models.Model):
@@ -53,7 +53,9 @@ class SurvexFile(models.Model):
survexdirectory.save()
self.survexdirectory = survexdirectory
self.save()
def __str__(self):
return self.path
class SurvexStationLookUpManager(models.Manager):
def lookup(self, name):
@@ -122,11 +124,11 @@ class SurvexBlock(models.Model):
class Meta:
ordering = ('id',)
# Don't change from the original as that breaks troggle webpages and internal referencing!
# def __str__(self):
# return "[SurvexBlock:"+ str(self.name) + "-path:" + \
# str(self.survexpath) + "-cave:" + \
# str(self.cave) + "]"
def __str__(self):
return "[SurvexBlock:"+ str(self.name) + "-path:" + \
str(self.survexpath) + "-cave:" + \
str(self.cave) + "]"
def __str__(self):
return self.name and str(self.name) or 'no name'
@@ -134,40 +136,19 @@ class SurvexBlock(models.Model):
return True
def GetPersonroles(self):
'''To do: excise the 'role' bit of this while retaining personrole
which is used in some later logic
'''
But apparently never used !?
'''
res = [ ]
for personrole in self.survexpersonrole_set.order_by('personexpedition'):
# if res and res[-1]['person'] == personrole.personexpedition.person:
# res[-1]['roles'] += ", " + str(personrole.nrole)
# else:
# res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year, 'roles':str(personrole.nrole)})
res.append({'person':personrole.personexpedition.person, 'expeditionyear':personrole.personexpedition.expedition.year})
return res
def DayIndex(self):
return list(self.expeditionday.survexblock_set.all()).index(self)
#
# member of a SurvexBlock
#
# ROLE_CHOICES = (
# ('insts','Instruments'),
# ('dog','Other'),
# ('notes','Notes'),
# ('pics','Pictures'),
# ('tape','Tape measure'),
# ('useless','Useless'),
# ('helper','Helper'),
# ('disto','Disto'),
# ('consultant','Consultant'),
# )
class SurvexPersonRole(models.Model):
survexblock = models.ForeignKey('SurvexBlock',on_delete=models.CASCADE)
# nrole = models.CharField(choices=ROLE_CHOICES, max_length=200, blank=True, null=True)
# increasing levels of precision
personname = models.CharField(max_length=100)
person = models.ForeignKey('Person', blank=True, null=True,on_delete=models.SET_NULL)
@@ -176,7 +157,7 @@ class SurvexPersonRole(models.Model):
expeditionday = models.ForeignKey("ExpeditionDay", null=True,on_delete=models.SET_NULL)
def __str__(self):
return str(self.person) + " - " + str(self.survexblock) + " - " + str(self.nrole)
return str(self.person) + " - " + str(self.survexblock)
class Wallet(models.Model):
fpath = models.CharField(max_length=200)
@@ -189,7 +170,7 @@ class Wallet(models.Model):
return urljoin(settings.URL_ROOT, reverse('singlewallet', kwargs={"path":re.sub("#", "%23", self.walletname)}))
def __str__(self):
return str(self.walletname) + " (Survey Scans Folder)"
return str(self.walletname) + " (Wallet)"
class SingleScan(models.Model):
ffile = models.CharField(max_length=200)
@@ -216,4 +197,8 @@ class DrawingFile(models.Model):
survexfiles = models.ManyToManyField("SurvexFile") # direct link to SVX files - not populated yet
class Meta:
ordering = ('dwgpath',)
ordering = ('dwgpath',)
def __str__(self):
return "Drawing File: " + str(self.dwgname) + " (" + str(self.filesize) + " bytes)"