summaryrefslogtreecommitdiffstats
path: root/core/views
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2021-04-23 03:07:21 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2021-04-23 03:07:21 +0100
commitdbd186e299fecd8f10f3dca0a88b78f842b0c59b (patch)
treecf90218918c0896ad770bcceb69f1e7df0d8c097 /core/views
parent1a4be0f02e8ca2536bb754c7285c005478ad047a (diff)
downloadtroggle-dbd186e299fecd8f10f3dca0a88b78f842b0c59b.tar.gz
troggle-dbd186e299fecd8f10f3dca0a88b78f842b0c59b.tar.bz2
troggle-dbd186e299fecd8f10f3dca0a88b78f842b0c59b.zip
make ?reload private and clean old error msgs
Diffstat (limited to 'core/views')
-rw-r--r--core/views/logbooks.py25
-rw-r--r--core/views/other.py22
2 files changed, 32 insertions, 15 deletions
diff --git a/core/views/logbooks.py b/core/views/logbooks.py
index 05faa64..454483c 100644
--- a/core/views/logbooks.py
+++ b/core/views/logbooks.py
@@ -57,9 +57,22 @@ def expedition(request, expeditionname):
By specifying a '0' for the expected number of entries in the logbook cache, this forces the parser to
re-parse the original logbook HTML file.
'''
- if "reload" in request.GET:
- this_expedition = Expedition.objects.get(year=int(expeditionname))
- LoadLogbookForExpedition(this_expedition, 0) # 0 means re-parse
+ if request.user.is_authenticated:
+ if "reload" in request.GET:
+ this_expedition = Expedition.objects.get(year=int(expeditionname))
+ # Need to delete the exisitng entries or we get duplicaiton
+ entries = this_expedition.logbookentry_set.all()
+ print(f'! - expo {expeditionname} {len(entries)} entries')
+ for entry in entries:
+ print(f'! - delete entry: "{entry}"')
+ entry.delete()
+ entries = this_expedition.logbookentry_set.all()
+ print(f'! - expo {expeditionname} {len(entries)} entries')
+ LoadLogbookForExpedition(this_expedition, 0) # 0 means re-parse
+ logged_in = True
+ else:
+ logged_in = False
+
ts = TROG['pagecache']['expedition']
if settings.CACHEDPAGES:
@@ -67,7 +80,7 @@ def expedition(request, expeditionname):
#print(f'! - expo {expeditionname} CACHEDPAGES {nexpos} expo pages in cache.')
if expeditionname in ts:
#print('! - expo {expeditionanme} using cached page')
- return render(request,'expedition.html', ts[expeditionname] )
+ return render(request,'expedition.html', { **ts[expeditionname], 'logged_in' : logged_in })
this_expedition = Expedition.objects.get(year=int(expeditionname))
@@ -88,11 +101,11 @@ def expedition(request, expeditionname):
ts[expeditionname] = {'expedition': this_expedition, 'expeditions':expeditions,
'personexpeditiondays':personexpeditiondays, 'settings':settings,
- 'dateditems': dateditems }
+ 'dateditems': dateditems}
TROG['pagecache']['expedition'][expeditionname] = ts[expeditionname]
nexpos = len( TROG['pagecache']['expedition'])
#print(f'! - expo {expeditionname} pre-render N expos:{nexpos}')
- return render(request,'expedition.html', ts[expeditionname] )
+ return render(request,'expedition.html', { **ts[expeditionname], 'logged_in' : logged_in } )
# def get_absolute_url(self): # seems to have come seriously adrift. This should be in a class?!
diff --git a/core/views/other.py b/core/views/other.py
index 639ea5f..9a12b1d 100644
--- a/core/views/other.py
+++ b/core/views/other.py
@@ -41,11 +41,15 @@ def todos(request, module):
'''
from troggle.core.TESTS.tests import todo as tests
from troggle.core.views.logbooks import todo as viewlogbooks
+ from troggle.parsers.logbooks import todo as parserslogbooks
from troggle.core.forms import todo as forms
+ from troggle.core.templatetags.wiki_markup import todo as wiki
tododict = {'views/other': todo,
'tests': tests,
'views/logbooks': viewlogbooks,
- 'core/forms': forms}
+ 'parsers/logbooks': parserslogbooks,
+ 'core/forms': forms,
+ 'core/templatetags/wiki_markup': wiki}
return render(request,'core/todos.html', {'tododict': tododict})
def troggle404(request): # cannot get this to work. Handler404 in urls.py not right syntax
@@ -215,25 +219,25 @@ def newfile(request, pslug = None):
return render(request, 'editfile.html', {'fileForm': fileform, })
@login_required_if_public
-def simpleupload(request):
- print(f'! - FORM simpleupload - start')
+def scanupload(request, year='2050'):
+ print(f'! - FORM scanupload - start')
if request.method == 'POST':
form = SimpleUploadFileForm(request.POST,request.FILES)
if form.is_valid():
#form.save() # comment out so nothing saved in MEDIA_ROOT/fileuploads
f = request.FILES["simplefile"]
w = request.POST["title"]
- print(f'! - FORM simpleupload uploaded {f.name}')
- fs = FileSystemStorage(os.path.join(settings.SURVEY_SCANS, '2021', w))
+ print(f'! - FORM scanupload uploaded {f.name}')
+ fs = FileSystemStorage(os.path.join(settings.SURVEY_SCANS, year, w))
actual_saved = fs.save(f.name, content=f) # name may chnage to avoid clash
- # INSERT check if name is chnaged, to allow user to abort and rename - or lets do a chaecjk anyway.
+ # INSERT check if name is changed, to allow user to abort and rename - or lets do a chaecjk anyway.
- print(f'! - FORM simpleupload {actual_saved}')
+ print(f'! - FORM scanupload {actual_saved}')
form = SimpleUploadFileForm()
- return render(request, 'simpleupload.html', {'form': form,'filesaved': True, 'actual_saved': actual_saved})
+ return render(request, 'scanuploadform.html', {'form': form,'filesaved': True, 'actual_saved': actual_saved})
else:
form = SimpleUploadFileForm()
- return render(request, 'simpleupload.html', {'form':form,})
+ return render(request, 'scanuploadform.html', {'form':form,})