From c80fd0c573626ed5da1ac05c03b6eb3ec7bb28df Mon Sep 17 00:00:00 2001 From: Keshav Garg Date: Wed, 31 Jul 2019 19:30:39 +0530 Subject: [PATCH] community/: Add a form for adding calendar events Not everyone, will be able to fill forms. Only the logged in users will be able to fill them and some of the forms, can only be filled by developers or contributors who are a part of more than one team. At every step, the check is performed whether the user is authenticated or not, to avoid false form submissions. Closes https://github.com/coala/community/issues/270 --- community/forms.py | 25 +++++++++++++++ community/views.py | 11 ++++++- static/js/main.js | 1 + templates/community_forms.html | 56 +++++++++++++++++++++++++++++++++- 4 files changed, 91 insertions(+), 2 deletions(-) diff --git a/community/forms.py b/community/forms.py index f4d95dcf..25c28935 100644 --- a/community/forms.py +++ b/community/forms.py @@ -104,3 +104,28 @@ class CommunityGoogleForm(forms.Form): help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS', widget=forms.TextInput(attrs={'autocomplete': 'off'}) ) + + +class CommunityEvent(forms.Form): + user = forms.CharField( + max_length=50, label='GitHub Username', + widget=forms.TextInput(attrs={'autocomplete': 'off'}) + ) + title = forms.CharField( + max_length=300, label='Event Title', + widget=forms.TextInput(attrs={'autocomplete': 'off'}) + ) + description = forms.CharField( + max_length=1000, label='Event Description', required=False, + widget=forms.Textarea(attrs={'autocomplete': 'off'}) + ) + start_date_time = forms.DateTimeField( + label='Event occurrence date and time(in UTC)', + help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS', + widget=forms.TextInput(attrs={'autocomplete': 'off'}) + ) + end_date_time = forms.DateTimeField( + label='Event end date and time(in UTC)', required=False, + help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS', + widget=forms.TextInput(attrs={'autocomplete': 'off'}) + ) diff --git a/community/views.py b/community/views.py index 5a4e22d9..a3e2ce67 100644 --- a/community/views.py +++ b/community/views.py @@ -12,7 +12,7 @@ get_org_name, get_remote_url ) -from .forms import JoinCommunityForm, CommunityGoogleForm +from .forms import JoinCommunityForm, CommunityGoogleForm, CommunityEvent from data.models import Team from gamification.models import Participant as GamificationParticipant from meta_review.models import Participant as MetaReviewer @@ -42,6 +42,14 @@ def initialize_org_context_details(): return org_details +def get_community_event_form_variables(context): + context['community_event_form'] = CommunityEvent() + context['community_event_form_name'] = os.environ.get( + 'CALENDAR_NETLIFY_FORM_NAME', None + ) + return context + + def get_community_google_form_variables(context): context['community_google_form'] = CommunityGoogleForm() context['community_google_form_name'] = os.environ.get( @@ -55,6 +63,7 @@ def get_header_and_footer(context): context['travisLink'] = Travis.TRAVIS_BUILD_WEB_URL context['org'] = initialize_org_context_details() context = get_community_google_form_variables(context) + context = get_community_event_form_variables(context) print('Running on Travis: {}, build link: {}'.format(context['isTravis'], context['travisLink'] )) diff --git a/static/js/main.js b/static/js/main.js index 67eb0e9a..ed9d231c 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -129,6 +129,7 @@ $(document).ready(function(){ $('.form-submission-popup').css('display', 'none'); $('.oauth-error').css('display', 'none'); $('.community-form').css('display', 'none'); + $('form').css('display', 'none'); }); logout_user_el.click(function () { diff --git a/templates/community_forms.html b/templates/community_forms.html index d04d92e4..a8b31d28 100644 --- a/templates/community_forms.html +++ b/templates/community_forms.html @@ -50,4 +50,58 @@
- \ No newline at end of file + + +