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): | class AddSpeakerForm(forms.Form): | ||||||
| 
 | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     email = forms.EmailField( |     email = forms.EmailField( | ||||||
|         label=_("Email address of new speaker (use their email address, not yours)") |         label=_("Email address of new speaker (use their email address, not yours)") | ||||||
|     ) |     ) | ||||||
|  | @ -33,6 +35,8 @@ class AddSpeakerForm(forms.Form): | ||||||
| 
 | 
 | ||||||
| class SupportingDocumentCreateForm(forms.ModelForm): | class SupportingDocumentCreateForm(forms.ModelForm): | ||||||
| 
 | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = SupportingDocument |         model = SupportingDocument | ||||||
|         fields = [ |         fields = [ | ||||||
|  |  | ||||||
|  | @ -5,6 +5,9 @@ from symposion.reviews.models import Review, Comment, ProposalMessage, VOTES | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ReviewForm(forms.ModelForm): | class ReviewForm(forms.ModelForm): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Review |         model = Review | ||||||
|         fields = ["vote", "comment"] |         fields = ["vote", "comment"] | ||||||
|  | @ -18,18 +21,27 @@ class ReviewForm(forms.ModelForm): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ReviewCommentForm(forms.ModelForm): | class ReviewCommentForm(forms.ModelForm): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Comment |         model = Comment | ||||||
|         fields = ["text"] |         fields = ["text"] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class SpeakerCommentForm(forms.ModelForm): | class SpeakerCommentForm(forms.ModelForm): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = ProposalMessage |         model = ProposalMessage | ||||||
|         fields = ["message"] |         fields = ["message"] | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class BulkPresentationForm(forms.Form): | class BulkPresentationForm(forms.Form): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     talk_ids = forms.CharField( |     talk_ids = forms.CharField( | ||||||
|         label=_("Talk ids"), |         label=_("Talk ids"), | ||||||
|         max_length=500, |         max_length=500, | ||||||
|  |  | ||||||
|  | @ -14,6 +14,8 @@ from symposion.schedule.models import (Day, Presentation, Room, SlotKind, Slot, | ||||||
| 
 | 
 | ||||||
| class SlotEditForm(forms.Form): | class SlotEditForm(forms.Form): | ||||||
| 
 | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     def __init__(self, *args, **kwargs): |     def __init__(self, *args, **kwargs): | ||||||
|         self.slot = kwargs.pop("slot") |         self.slot = kwargs.pop("slot") | ||||||
|         super(SlotEditForm, self).__init__(*args, **kwargs) |         super(SlotEditForm, self).__init__(*args, **kwargs) | ||||||
|  | @ -48,6 +50,9 @@ class SlotEditForm(forms.Form): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class ScheduleSectionForm(forms.Form): | class ScheduleSectionForm(forms.Form): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     ROOM_KEY = 'room' |     ROOM_KEY = 'room' | ||||||
|     DATE_KEY = 'date' |     DATE_KEY = 'date' | ||||||
|     START_KEY = 'time_start' |     START_KEY = 'time_start' | ||||||
|  |  | ||||||
|  | @ -5,6 +5,8 @@ from symposion.speakers.models import Speaker | ||||||
| 
 | 
 | ||||||
| class SpeakerForm(forms.ModelForm): | class SpeakerForm(forms.ModelForm): | ||||||
| 
 | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Speaker |         model = Speaker | ||||||
|         fields = [ |         fields = [ | ||||||
|  |  | ||||||
|  | @ -8,6 +8,9 @@ from symposion.sponsorship.models import Sponsor, SponsorBenefit | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class SponsorApplicationForm(forms.ModelForm): | class SponsorApplicationForm(forms.ModelForm): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     def __init__(self, *args, **kwargs): |     def __init__(self, *args, **kwargs): | ||||||
|         self.user = kwargs.pop("user") |         self.user = kwargs.pop("user") | ||||||
|         kwargs.update({ |         kwargs.update({ | ||||||
|  | @ -37,6 +40,9 @@ class SponsorApplicationForm(forms.ModelForm): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class SponsorDetailsForm(forms.ModelForm): | class SponsorDetailsForm(forms.ModelForm): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     class Meta: |     class Meta: | ||||||
|         model = Sponsor |         model = Sponsor | ||||||
|         fields = [ |         fields = [ | ||||||
|  | @ -48,6 +54,9 @@ class SponsorDetailsForm(forms.ModelForm): | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class SponsorBenefitsInlineFormSet(BaseInlineFormSet): | class SponsorBenefitsInlineFormSet(BaseInlineFormSet): | ||||||
|  | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     def __init__(self, *args, **kwargs): |     def __init__(self, *args, **kwargs): | ||||||
|         kwargs['queryset'] = kwargs.get('queryset', self.model._default_manager).exclude(benefit__type="option") |         kwargs['queryset'] = kwargs.get('queryset', self.model._default_manager).exclude(benefit__type="option") | ||||||
|         super(SponsorBenefitsInlineFormSet, self).__init__(*args, **kwargs) |         super(SponsorBenefitsInlineFormSet, self).__init__(*args, **kwargs) | ||||||
|  |  | ||||||
|  | @ -11,6 +11,8 @@ from symposion.teams.models import Membership | ||||||
| 
 | 
 | ||||||
| class TeamInvitationForm(forms.Form): | class TeamInvitationForm(forms.Form): | ||||||
| 
 | 
 | ||||||
|  |     required_css_class = 'label-required' | ||||||
|  | 
 | ||||||
|     email = forms.EmailField(label=_("Email"), |     email = forms.EmailField(label=_("Email"), | ||||||
|                              help_text=_("email address must be that of an account on this " |                              help_text=_("email address must be that of an account on this " | ||||||
|                                          "conference site")) |                                          "conference site")) | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Sachi King
						Sachi King