mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2025-12-14 20:27:10 +00:00
file upload integration test working
This commit is contained in:
@@ -8,7 +8,7 @@ from django.contrib.admin.widgets import AdminDateWidget
|
||||
|
||||
#from tinymce.widgets import TinyMCE
|
||||
|
||||
from troggle.core.models.troggle import Person, PersonExpedition, Expedition, SimpleFileModel
|
||||
from troggle.core.models.troggle import Person, PersonExpedition, Expedition
|
||||
from troggle.core.models.caves import Cave, LogbookEntry, QM, Entrance, CaveAndEntrance
|
||||
|
||||
'''These are all the Forms used by troggle
|
||||
@@ -107,55 +107,5 @@ class EntranceLetterForm(ModelForm):
|
||||
model = CaveAndEntrance
|
||||
exclude = ('cave', 'entrance')
|
||||
|
||||
def get_name(pe):
|
||||
if pe.nickname:
|
||||
return pe.nickname
|
||||
else:
|
||||
return pe.person.first_name
|
||||
|
||||
class UploadFileForm(forms.Form):
|
||||
"""Only called by views.others.newFile() which seems to be only about logbook files.
|
||||
"""
|
||||
title = forms.CharField(max_length=50)
|
||||
file = forms.FileField()
|
||||
#html = forms.CharField(widget=TinyMCE(attrs={'cols': 80, 'rows': 30}))
|
||||
html = forms.CharField(widget=forms.Textarea(attrs={"cols":80, "rows":20}))
|
||||
lon_utm = forms.FloatField(required=False)
|
||||
lat_utm = forms.FloatField(required=False)
|
||||
slug = forms.CharField(max_length=50)
|
||||
date = forms.DateField(required=False)
|
||||
survey_point = forms.CharField()
|
||||
|
||||
# Because this has EXECUTABLE statements in its signature (the fields) they get
|
||||
# executed when this module is LOADED. Which barfs horribly.
|
||||
# so all put in an __init__ method instead pending deletion or rewriting
|
||||
def __init__(self):
|
||||
#This next line is the one that causes django.setup() to BARF LOUDLY
|
||||
caves = [cave.slug for cave in Cave.objects.all()]
|
||||
#caves.sort() # sort needs rewriting for python3
|
||||
caves = ["-----"] + caves
|
||||
cave = forms.ChoiceField([(c, c) for c in caves], required=False)
|
||||
|
||||
entrance = forms.ChoiceField([("-----", "Please select a cave"), ], required=False)
|
||||
|
||||
expeditions = [e.year for e in Expedition.objects.all()]
|
||||
expeditions.sort()
|
||||
expeditions = ["-----"] + expeditions
|
||||
expedition = forms.ChoiceField([(e, e) for e in expeditions], required=False)
|
||||
|
||||
qm = forms.ChoiceField([("-----", "Please select a cave"), ], required=False)
|
||||
logbookentry = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False)
|
||||
person = forms.ChoiceField([("-----", "Please select an expedition"), ], required=False)
|
||||
|
||||
|
||||
|
||||
class SimpleUploadFileForm(forms.ModelForm):
|
||||
"""New in April 2021
|
||||
"""
|
||||
class Meta:
|
||||
model = SimpleFileModel
|
||||
fields = ('title', 'simplefile',)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user