2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2025-01-19 01:12:32 +00:00

catch unknown scotsman error

This commit is contained in:
Philip Sargent 2021-04-20 22:58:41 +01:00
parent 3b0c6ef2ea
commit b4ba3c40eb
8 changed files with 30 additions and 39 deletions

View File

@ -373,7 +373,6 @@ class LogbookEntry(TroggleModel):
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:
@ -412,7 +411,7 @@ class LogbookEntry(TroggleModel):
return urljoin(settings.URL_ROOT, reverse('logbookentry',kwargs={'date':self.date,'slug':self.slug}))
def __str__(self):
return "%s: (%s)" % (self.date, self.title)
return f'{self.date}: {self.title}'
def get_next_by_id(self):
LogbookEntry.objects.get(id=self.id+1)
@ -507,7 +506,7 @@ class PersonTrip(TroggleModel):
return self.logbook_entry.cave and self.logbook_entry.cave or self.logbook_entry.place
def __str__(self):
return "%s (%s)" % (self.personexpedition, self.logbook_entry.date)
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):

View File

@ -70,6 +70,7 @@ class DataIssue(TroggleModel):
class Expedition(TroggleModel):
year = models.CharField(max_length=20, unique=True)
name = models.CharField(max_length=100)
logbookfile = models.CharField(max_length=100, blank=True, null=True)
def __str__(self):
return self.year

View File

@ -115,16 +115,13 @@ class Expeditions_jsonListView(ListView):
def person(request, first_name='', last_name='', ):
this_person = Person.objects.get(first_name = first_name, last_name = last_name)
try:
this_person = Person.objects.get(first_name = first_name, last_name = last_name)
return render(request,'person.html', {'person': this_person, })
except:
message = f'Person not found - possibly Scottish? (We have a name parser issue with Mc, Mac etc.)'
return render(request, 'errors/generic.html', {'message': message})
# This is for removing the reference to the user's profile, in case they set it to the wrong person
if request.method == 'GET':
if request.GET.get('clear_profile')=='True':
this_person.user=None
this_person.save()
return HttpResponseRedirect(reverse('profiles_select_profile'))
return render(request,'person.html', {'person': this_person, })
def get_person_chronology(personexpedition):

View File

@ -134,14 +134,12 @@ def ajax_QM_number(request):
return HttpResponse(res)
#print(" - newFile() is next in troggle/core/views/other.py")
@login_required_if_public
def newFile(request, pslug = None):
''' not known quite what this was for or where it fits in - original 2006 troggle idea never finished?
'''
if pslug:
previousfile = LogbookEntry.objects.get(slug = pslug, date = previousdate, expedition = expedition)
#assert previousfile.filename
if request.method == 'POST': # If the form has been submitted...
tripForm = TripForm(request.POST) # A form bound to the POST data
personTripFormSet = PersonTripFormSet(request.POST)
@ -175,16 +173,4 @@ def newFile(request, pslug = None):
return render(request, 'editfile.html', {'fileForm': fileform, })
@login_required_if_public
def deleteFile(request, expeditionyear, date = None, slug = None):
expedition = Expedition.objects.get(year=expeditionyear)
previousdate = datetime.date(*[int(x) for x in date.split("-")])
previouslbe = LogbookEntry.objects.get(slug = slug, date = previousdate, expedition = expedition)
delLogbookEntry(previouslbe)
return HttpResponseRedirect(reverse('expedition', args=[expedition.year])) # Redirect after POST
def delFile(f):
for pt in lbe.persontrip_set.all():
pt.delete()
lbe.delete()
os.remove(lbe.filename)

View File

@ -447,11 +447,14 @@ def LoadLogbookForExpedition(expedition, expect):
if expedition.year in yearlinks:
logbookfile = os.path.join(expologbase, yearlinks[expedition.year][0])
expedition.logbookfile = yearlinks[expedition.year][0]
parsefunc = yearlinks[expedition.year][1]
else:
logbookfile = os.path.join(expologbase, expedition.year, settings.DEFAULT_LOGBOOK_FILE)
expedition.logbookfile = settings.DEFAULT_LOGBOOK_FILE
parsefunc = settings.DEFAULT_LOGBOOK_PARSER
cache_filename = logbookfile + ".cache"
expedition.save()
try:
bad_cache = False

View File

@ -13,7 +13,15 @@
<div class='space'></div>
<div class='align-center'>
<h3>There has been an error.</h3>
<p>We are terribly sorry but an unknown fault has occurred. </p>
{% if message %}
{{message}}
{% else %}
<p>We are terribly sorry but an unknown fault has occurred. </p>
{% endif %})
</div>

View File

@ -1,4 +1,5 @@
{% extends "base.html" %}
<!-- logbookentry.html - this text visible because this template has been included -->
{% load wiki_markup %}
{% block title %}Logbook {{logbookentry.id}}{% endblock %}
@ -10,12 +11,14 @@
<h2>{{logbookentry.title|safe}}</h2>
<div id="related">
<p><a href="{{ logbookentry.expedition.get_absolute_url }}">{{logbookentry.expedition.name}}</a></p>
<p><a href="{{ logbookentry.expedition.get_absolute_url }}">{{logbookentry.expedition.name}}</a>
&nbsp;&nbsp;&nbsp;&nbsp;<a href="/years/{{logbookentry.expedition.logbookfile}}">Full logbook</a>
</p>
{% if logbookentry.cave %}
<p>place: <a href="{{ logbookentry.cave.get_absolute_url }}">{{logbookentry.place}}</p>
{% else %}
<p>{{logbookentry.place}}</p>
<p>{{logbookentry.place|safe}}</p>
{% endif %}
<p>
@ -67,16 +70,9 @@
<div id="col1">
<div class="logbookentry">
<b>{{logbookentry.date|date:"D d M Y"}}</b>
{% if logbookentry.entry_type == "html" %}
<p>{{logbookentry.text|safe}}</p>
{% else %}
{{logbookentry.text|wiki_to_html}}
{% endif %}
<p>{{logbookentry.text|safe}}</p>
</div>
</div>
</div>
{% if logbookentry.filename %}<a href="{% url "editLogBookEntry" expeditionyear=logbookentry.expedition.year pdate=logbookentry.date pslug=logbookentry.slug %}">Edit</a> <a href="{% url "deleteLogBookEntry" expeditionyear=logbookentry.expedition.year date=logbookentry.date slug=logbookentry.slug %}">Delete</a>{%endif%}
{% endblock %}

View File

@ -1,4 +1,5 @@
{% extends "base.html" %}
<!-- logbookentry.html - this text visible because this template has been included -->
{% load csrffaker %}
{% block title %}Logbook {{logbookentry.id}}{% endblock %}
{% block head %}