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 e2f0fd60..15f5346a 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/forms.js b/static/js/forms.js index 068046b2..b1d8c5e7 100644 --- a/static/js/forms.js +++ b/static/js/forms.js @@ -22,7 +22,7 @@ $(document).ready(function () { username_input.attr('value', authenticated_username || 'Anonymous User'); username_input.attr('disabled', true); - $('form').attr( + $('.community-form form').attr( 'action',window.location.pathname + '?form_submitted=True&form_type=community' ); @@ -86,7 +86,7 @@ $(document).ready(function () { display_form_or_error(mentor_students_form); }); - $(':input').focusin(function () { + $('.community-form :input').focusin(function () { if (is_user_authenticated===undefined && authenticated_username===undefined) { $('.community-form').css('display', 'none'); diff --git a/static/js/main.js b/static/js/main.js index 03a6717a..f9b2e2c6 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -128,6 +128,7 @@ $(document).ready(function(){ $('.form-submission-popup').css('display', 'none'); $('.oauth-error').css('display', 'none'); $('.community-form').css('display', 'none'); + $('.community-form form').css('display', 'none'); }); logout_user_el.click(function () { diff --git a/templates/community_forms.html b/templates/community_forms.html index feeae874..1666a629 100644 --- a/templates/community_forms.html +++ b/templates/community_forms.html @@ -51,3 +51,58 @@