helpful comments on form

This commit is contained in:
Philip Sargent 2023-07-26 17:38:19 +03:00
parent 0706d5dc77
commit 6482aa697f
2 changed files with 31 additions and 22 deletions

View File

@ -119,68 +119,79 @@ class CaveForm(ModelForm):
class EntranceForm(ModelForm): class EntranceForm(ModelForm):
"""Only those fields for which we want to override defaults are listed here """Only those fields for which we want to override defaults are listed here
the other fields are present on the form, but use the default presentaiton style the other fields are present on the form, but use the default presentation style
""" """
name = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "45"})) name = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "45"}))
entrance_description = forms.CharField( entrance_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
explorers = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "45"})) explorers = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "45"}))
# explorers = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) # explorers = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10}))
map_description = forms.CharField( map_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
location_description = forms.CharField( location_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
lastvisit = forms.CharField( lastvisit = forms.CharField(
required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Date of last visit" required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Date of last visit, e.g. 2023-07-11"
) )
approach = forms.CharField( approach = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
underground_description = forms.CharField( underground_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
photo = forms.CharField( photo = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
marking_comment = forms.CharField( marking_comment = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
findability_description = forms.CharField( findability_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
other_description = forms.CharField( other_description = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
) )
bearings = forms.CharField( bearings = forms.CharField(
required=False, required=False,
widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter page content (using HTML)"}), widget=HTMLarea(attrs={"height": "80%", "rows": 20, "placeholder": "Enter text (using HTML)"}),
)
tag_station = forms.CharField(
required=False,
widget=forms.TextInput(attrs={"size": "50"}), label="Tag station: Survex station id, e.g. 1623.p2023-xx-01"
)
exact_station = forms.CharField(
required=False,
widget=forms.TextInput(attrs={"size": "50"}), label="Exact station: Survex station id, e.g. 1623.2023-xx-01.2"
)
other_station = forms.CharField(
required=False,
widget=forms.TextInput(attrs={"size": "50"}), label="Other station: Survex station id, e.g. 1623.2023-xx-01.33"
) )
other_station = forms.CharField(required=False)
tag_station = forms.CharField(required=False)
exact_station = forms.CharField(required=False)
northing = forms.CharField(required=False) northing = forms.CharField(required=False)
easting = forms.CharField(required=False) easting = forms.CharField(required=False)
lat_wgs84 = forms.CharField(required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Latitude (WSG84)") lat_wgs84 = forms.CharField(
required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Latitude (WSG84) - if no other location"
)
long_wgs84 = forms.CharField( long_wgs84 = forms.CharField(
required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Longitude (WSG84)" required=False, widget=forms.TextInput(attrs={"size": "10"}), label="Longitude (WSG84) - if no other location"
) )
alt = forms.CharField(required=False, label="Altitude (m)") alt = forms.CharField(required=False, label="Altitude (m)")
url = forms.CharField(required=False, label="URL [usually blank]", widget=forms.TextInput(attrs={"size": "45"})) url = forms.CharField(required=False, label="URL [usually blank]", widget=forms.TextInput(attrs={"size": "45"}))
field_order = ['name', 'entrance_description', 'explorers', 'map_description', 'location_description', 'lastvisit', 'approach', 'underground_description', 'photo', 'marking_comment', 'findability_description', 'other_description', 'bearings', 'other_station', 'tag_station', 'exact_station', 'northing', 'easting', 'lat_wgs84', 'long_wgs84', 'alt', 'url'] field_order = ['name', 'entrance_description', 'explorers', 'map_description', 'location_description', 'lastvisit', 'approach', 'underground_description', 'photo', 'marking_comment', 'findability_description', 'other_description', 'bearings', 'tag_station', 'exact_station', 'other_station', 'northing', 'easting', 'lat_wgs84', 'long_wgs84', 'alt', 'url']
class Meta: class Meta:
model = Entrance model = Entrance

View File

@ -485,10 +485,8 @@ def edit_entrance(request, path="", caveslug=None, entslug=None):
entrance_letter.entrance = entrance entrance_letter.entrance = entrance
entrance_letter.save() entrance_letter.save()
if not entrance.filename:
print(f"! BARF - why no filename set? '{entslug}' letter:{entletter.cleaned_data['entrance_letter']}")
entrance_file = entrance.file_output() entrance_file = entrance.file_output()
print(f"Online edit of entrance {entrance.slug}") # print(f"Online edit of entrance {entrance.slug}")
cave_file = cave.file_output() cave_file = cave.file_output()
write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}") write_and_commit([entrance_file, cave_file], f"Online edit of entrance {entrance.slug}")
return HttpResponseRedirect("/" + cave.url) return HttpResponseRedirect("/" + cave.url)