Add a CSS class on required fields labels
This makes it possible to add a ' *' required notifier to labels without needing a bunch of custom form code in templates.
This commit is contained in:
		
							parent
							
								
									997380152e
								
							
						
					
					
						commit
						fb5eaea880
					
				
					 6 changed files with 34 additions and 0 deletions
				
			
		|  | @ -10,6 +10,8 @@ from symposion.proposals.models import SupportingDocument | |||
| 
 | ||||
| class AddSpeakerForm(forms.Form): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     email = forms.EmailField( | ||||
|         label=_("Email address of new speaker (use their email address, not yours)") | ||||
|     ) | ||||
|  | @ -33,6 +35,8 @@ class AddSpeakerForm(forms.Form): | |||
| 
 | ||||
| class SupportingDocumentCreateForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = SupportingDocument | ||||
|         fields = [ | ||||
|  |  | |||
|  | @ -5,6 +5,9 @@ from symposion.reviews.models import Review, Comment, ProposalMessage, VOTES | |||
| 
 | ||||
| 
 | ||||
| class ReviewForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = Review | ||||
|         fields = ["vote", "comment"] | ||||
|  | @ -18,18 +21,27 @@ class ReviewForm(forms.ModelForm): | |||
| 
 | ||||
| 
 | ||||
| class ReviewCommentForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = Comment | ||||
|         fields = ["text"] | ||||
| 
 | ||||
| 
 | ||||
| class SpeakerCommentForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = ProposalMessage | ||||
|         fields = ["message"] | ||||
| 
 | ||||
| 
 | ||||
| class BulkPresentationForm(forms.Form): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     talk_ids = forms.CharField( | ||||
|         label=_("Talk ids"), | ||||
|         max_length=500, | ||||
|  |  | |||
|  | @ -14,6 +14,8 @@ from symposion.schedule.models import (Day, Presentation, Room, SlotKind, Slot, | |||
| 
 | ||||
| class SlotEditForm(forms.Form): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         self.slot = kwargs.pop("slot") | ||||
|         super(SlotEditForm, self).__init__(*args, **kwargs) | ||||
|  | @ -48,6 +50,9 @@ class SlotEditForm(forms.Form): | |||
| 
 | ||||
| 
 | ||||
| class ScheduleSectionForm(forms.Form): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     ROOM_KEY = 'room' | ||||
|     DATE_KEY = 'date' | ||||
|     START_KEY = 'time_start' | ||||
|  |  | |||
|  | @ -5,6 +5,8 @@ from symposion.speakers.models import Speaker | |||
| 
 | ||||
| class SpeakerForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = Speaker | ||||
|         fields = [ | ||||
|  |  | |||
|  | @ -8,6 +8,9 @@ from symposion.sponsorship.models import Sponsor, SponsorBenefit | |||
| 
 | ||||
| 
 | ||||
| class SponsorApplicationForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         self.user = kwargs.pop("user") | ||||
|         kwargs.update({ | ||||
|  | @ -37,6 +40,9 @@ class SponsorApplicationForm(forms.ModelForm): | |||
| 
 | ||||
| 
 | ||||
| class SponsorDetailsForm(forms.ModelForm): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     class Meta: | ||||
|         model = Sponsor | ||||
|         fields = [ | ||||
|  | @ -48,6 +54,9 @@ class SponsorDetailsForm(forms.ModelForm): | |||
| 
 | ||||
| 
 | ||||
| class SponsorBenefitsInlineFormSet(BaseInlineFormSet): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     def __init__(self, *args, **kwargs): | ||||
|         kwargs['queryset'] = kwargs.get('queryset', self.model._default_manager).exclude(benefit__type="option") | ||||
|         super(SponsorBenefitsInlineFormSet, self).__init__(*args, **kwargs) | ||||
|  |  | |||
|  | @ -11,6 +11,8 @@ from symposion.teams.models import Membership | |||
| 
 | ||||
| class TeamInvitationForm(forms.Form): | ||||
| 
 | ||||
|     required_css_class = 'label-required' | ||||
| 
 | ||||
|     email = forms.EmailField(label=_("Email"), | ||||
|                              help_text=_("email address must be that of an account on this " | ||||
|                                          "conference site")) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Sachi King
						Sachi King