from django.forms import ModelForm from models import Cave, Person, PersonExpedition, LogbookEntry, QM, Expedition, Entrance, CaveAndEntrance import django.forms as forms from django.forms.models import modelformset_factory from django.contrib.admin.widgets import AdminDateWidget import string from datetime import date from tinymce.widgets import TinyMCE class CaveForm(ModelForm): underground_description = forms.CharField(required = False, widget=forms.Textarea()) explorers = forms.CharField(required = False, widget=forms.Textarea()) equipment = forms.CharField(required = False, widget=forms.Textarea()) survey = forms.CharField(required = False, widget=forms.Textarea()) kataster_status = forms.CharField(required = False, widget=forms.Textarea()) underground_centre_line = forms.CharField(required = False, widget=forms.Textarea()) notes = forms.CharField(required = False, widget=forms.Textarea()) references = forms.CharField(required = False, widget=forms.Textarea()) slug = forms.CharField(required = True) url = forms.CharField(required = True) class Meta: model = Cave exclude = ("filename",) class VersionControlCommentForm(forms.Form): description_of_change = forms.CharField(required = True, widget=forms.Textarea()) class EntranceForm(ModelForm): #underground_description = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 30})) #explorers = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #equipment = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #survey = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #kataster_status = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #underground_centre_line = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #notes = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) #references = forms.CharField(required = False, widget=TinyMCE(attrs={'cols': 80, 'rows': 10})) other_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry tag_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry exact_station = forms.CharField(required=False) # Trying to change this to a singl;e line entry northing = forms.CharField(required=False) # Trying to change this to a singl;e line entry easting = forms.CharField(required=False) # Trying to change this to a singl;e line entry alt = forms.CharField(required=False) # Trying to change this to a singl;e line entry slug = forms.CharField() class Meta: model = Entrance exclude = ("cached_primary_slug", "filename",) CaveAndEntranceFormSet = modelformset_factory(CaveAndEntrance, exclude=('cave')) #class PersonForm(ModelForm): # class Meta: # model = Person #class LogbookEntryForm(ModelForm): # class Meta: # model = LogbookEntry# # def wikiLinkHints(LogbookEntry=None): # """ # This function returns html-formatted paragraphs for each of the # wikilink types that are related to this logbookentry. Each paragraph # contains a list of all of the related wikilinks. # # Perhaps an admin javascript solution would be better. # """ # res = ["Please use the following wikilinks, which are related to this logbook entry:"] # # res.append(r'
QMs found:') # for QM in LogbookEntry.instance.QMs_found.all(): # res.append(QM.wiki_link()) # res.append(r'
QMs ticked off:') # for QM in LogbookEntry.instance.QMs_ticked_off.all(): # res.append(QM.wiki_link()) # res.append(r'
People') # for persontrip in LogbookEntry.instance.persontrip_set.all(): # res.append(persontrip.wiki_link()) # res.append(r'
') # return string.join(res, r'