diff options
author | Sam Wenham <sam@wenhams.co.uk> | 2019-03-31 15:39:53 +0100 |
---|---|---|
committer | Sam Wenham <sam@wenhams.co.uk> | 2019-03-31 15:39:53 +0100 |
commit | 9df91b221b4992d29b90caa30ae5a417d5b750d0 (patch) | |
tree | dfd69110a1af8ce3442c47f590bb129ee323a3f1 /core | |
parent | 64a4842dcbcbe10c5edb057c0000659f2809c1f9 (diff) | |
download | troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.tar.gz troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.tar.bz2 troggle-9df91b221b4992d29b90caa30ae5a417d5b750d0.zip |
Support html and wiki logbook entrys
Move nearest_station to nearest_station_name and make nearest_station a foreign
key to SurvexStation
Lots of tidying
Diffstat (limited to 'core')
-rw-r--r-- | core/models.py | 53 | ||||
-rw-r--r-- | core/models_survex.py | 2 | ||||
-rw-r--r-- | core/templatetags/wiki_markup.py | 11 |
3 files changed, 34 insertions, 32 deletions
diff --git a/core/models.py b/core/models.py index 1b2875a..3d9041c 100644 --- a/core/models.py +++ b/core/models.py @@ -104,21 +104,19 @@ class Expedition(TroggleModel): def day_max(self): res = self.expeditionday_set.all() return res and res[len(res) - 1] or None - - + class ExpeditionDay(TroggleModel): expedition = models.ForeignKey("Expedition") date = models.DateField() class Meta: - ordering = ('date',) + ordering = ('date',) def GetPersonTrip(self, personexpedition): personexpeditions = self.persontrip_set.filter(expeditionday=self) return personexpeditions and personexpeditions[0] or None - - + # # single Person, can go on many years # @@ -247,18 +245,22 @@ class PersonExpedition(TroggleModel): # Single parsed entry from Logbook # 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. + + LOGBOOK_ENTRY_TYPES = ( + ("wiki", "Wiki style logbook"), + ("html", "Html style logbook") + ) + + date = models.DateTimeField()#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) expedition = models.ForeignKey(Expedition,blank=True,null=True) # yes this is double- - #author = models.ForeignKey(PersonExpedition,blank=True,null=True) # the person who writes it up doesn't have to have been on the trip. - # Re: the above- so this field should be "typist" or something, not "author". - AC 15 jun 09 - #MJG wants to KILL THIS, as it is typically redundant with PersonTrip.is_logbook_entry_author, in the rare it was not redundanty and of actually interest it could be added to the text. - title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH) - 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") - text = models.TextField() - slug = models.SlugField(max_length=50) - filename = models.CharField(max_length=200,null=True) + title = models.CharField(max_length=settings.MAX_LOGBOOK_ENTRY_TITLE_LENGTH) + 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") + text = models.TextField() + slug = models.SlugField(max_length=50) + filename = models.CharField(max_length=200,null=True) + entry_type = models.CharField(default="wiki",null=True,choices=LOGBOOK_ENTRY_TYPES,max_length=50) class Meta: verbose_name_plural = "Logbook Entries" @@ -297,7 +299,7 @@ class LogbookEntry(TroggleModel): if self.cave: nextQMnumber=self.cave.new_QM_number(self.date.year) else: - return none + return None return nextQMnumber def new_QM_found_link(self): @@ -307,6 +309,7 @@ class LogbookEntry(TroggleModel): def DayIndex(self): return list(self.expeditionday.logbookentry_set.all()).index(self) + # # 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) # @@ -452,7 +455,7 @@ class Cave(TroggleModel): elif self.unofficial_number: href = self.unofficial_number else: - href = official_name.lower() + href = self.official_name.lower() #return settings.URL_ROOT + '/cave/' + href + '/' return urlparse.urljoin(settings.URL_ROOT, reverse('cave',kwargs={'cave_id':href,})) @@ -744,17 +747,17 @@ class QM(TroggleModel): number = models.IntegerField(help_text="this is the sequential number in the year", ) GRADE_CHOICES=( - ('A', 'A: Large obvious lead'), - ('B', 'B: Average lead'), - ('C', 'C: Tight unpromising lead'), - ('D', 'D: Dig'), - ('X', 'X: Unclimbable aven') + ('A', 'A: Large obvious lead'), + ('B', 'B: Average lead'), + ('C', 'C: Tight unpromising lead'), + ('D', 'D: Dig'), + ('X', 'X: Unclimbable aven') ) grade = models.CharField(max_length=1, choices=GRADE_CHOICES) location_description = models.TextField(blank=True) - #should be a foreignkey to surveystation nearest_station_description = models.CharField(max_length=400,null=True,blank=True) - nearest_station = 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) area = models.CharField(max_length=100,blank=True,null=True) completion_description = models.TextField(blank=True,null=True) comment=models.TextField(blank=True,null=True) @@ -834,7 +837,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. def correctURL(self): return string.replace(self.file.url,r'#',r'%23') - + def __unicode__(self): return get_scan_path(self,'') diff --git a/core/models_survex.py b/core/models_survex.py index f6b3284..ed581a3 100644 --- a/core/models_survex.py +++ b/core/models_survex.py @@ -225,4 +225,4 @@ class TunnelFile(models.Model): class Meta: ordering = ('tunnelpath',) - + diff --git a/core/templatetags/wiki_markup.py b/core/templatetags/wiki_markup.py index 3bc5b07..2640594 100644 --- a/core/templatetags/wiki_markup.py +++ b/core/templatetags/wiki_markup.py @@ -7,7 +7,6 @@ from troggle.core.models import QM, DPhoto, LogbookEntry, Cave import re, urlparse register = template.Library() - @register.filter() def plusone(n): @@ -77,7 +76,7 @@ def wiki_to_html_short(value, autoescape=None): if number>1: return '<h'+num+'>'+matchobj.groups()[1]+'</h'+num+'>' else: - print 'morethanone' + print('morethanone') return matchobj.group() value = re.sub(r"(?m)^(=+)([^=]+)(=+)$",headerrepl,value) @@ -143,13 +142,13 @@ def wiki_to_html_short(value, autoescape=None): value = re.sub(photoSrcPattern,photoSrcRepl, value, re.DOTALL) #make cave links - value = re.sub("\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%scave/\1/">\1</a>' % settings.URL_ROOT, value, re.DOTALL) + value = re.sub(r"\[\[\s*cave:([^\s]+)\s*\s*\]\]", r'<a href="%scave/\1/">\1</a>' % settings.URL_ROOT, value, re.DOTALL) #make people links - value = re.sub("\[\[\s*person:(.+)\|(.+)\]\]",r'<a href="%sperson/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) + value = re.sub(r"\[\[\s*person:(.+)\|(.+)\]\]",r'<a href="%sperson/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) #make subcave links - value = re.sub("\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%ssubcave/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) + value = re.sub(r"\[\[\s*subcave:(.+)\|(.+)\]\]",r'<a href="%ssubcave/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) #make cavedescription links - value = re.sub("\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%scavedescription/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) + value = re.sub(r"\[\[\s*cavedescription:(.+)\|(.+)\]\]",r'<a href="%scavedescription/\1/">\2</a>' % settings.URL_ROOT, value, re.DOTALL) |