Skip to content

Commit c80fd0c

Browse files
committed
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 coala#270
1 parent 5584daf commit c80fd0c

File tree

4 files changed

+91
-2
lines changed

4 files changed

+91
-2
lines changed

community/forms.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,28 @@ class CommunityGoogleForm(forms.Form):
104104
help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS',
105105
widget=forms.TextInput(attrs={'autocomplete': 'off'})
106106
)
107+
108+
109+
class CommunityEvent(forms.Form):
110+
user = forms.CharField(
111+
max_length=50, label='GitHub Username',
112+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
113+
)
114+
title = forms.CharField(
115+
max_length=300, label='Event Title',
116+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
117+
)
118+
description = forms.CharField(
119+
max_length=1000, label='Event Description', required=False,
120+
widget=forms.Textarea(attrs={'autocomplete': 'off'})
121+
)
122+
start_date_time = forms.DateTimeField(
123+
label='Event occurrence date and time(in UTC)',
124+
help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS',
125+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
126+
)
127+
end_date_time = forms.DateTimeField(
128+
label='Event end date and time(in UTC)', required=False,
129+
help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS',
130+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
131+
)

community/views.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
get_org_name,
1313
get_remote_url
1414
)
15-
from .forms import JoinCommunityForm, CommunityGoogleForm
15+
from .forms import JoinCommunityForm, CommunityGoogleForm, CommunityEvent
1616
from data.models import Team
1717
from gamification.models import Participant as GamificationParticipant
1818
from meta_review.models import Participant as MetaReviewer
@@ -42,6 +42,14 @@ def initialize_org_context_details():
4242
return org_details
4343

4444

45+
def get_community_event_form_variables(context):
46+
context['community_event_form'] = CommunityEvent()
47+
context['community_event_form_name'] = os.environ.get(
48+
'CALENDAR_NETLIFY_FORM_NAME', None
49+
)
50+
return context
51+
52+
4553
def get_community_google_form_variables(context):
4654
context['community_google_form'] = CommunityGoogleForm()
4755
context['community_google_form_name'] = os.environ.get(
@@ -55,6 +63,7 @@ def get_header_and_footer(context):
5563
context['travisLink'] = Travis.TRAVIS_BUILD_WEB_URL
5664
context['org'] = initialize_org_context_details()
5765
context = get_community_google_form_variables(context)
66+
context = get_community_event_form_variables(context)
5867
print('Running on Travis: {}, build link: {}'.format(context['isTravis'],
5968
context['travisLink']
6069
))

static/js/main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ $(document).ready(function(){
129129
$('.form-submission-popup').css('display', 'none');
130130
$('.oauth-error').css('display', 'none');
131131
$('.community-form').css('display', 'none');
132+
$('form').css('display', 'none');
132133
});
133134

134135
logout_user_el.click(function () {

templates/community_forms.html

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,58 @@ <h5 class="text-center custom-green-color-font bold-text">
5050
<div class="apply-flex center-content submit-btn">
5151
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
5252
</div>
53-
</form>
53+
</form>
54+
55+
<form name="{{ community_event_form_name }}" method="post"
56+
netlify-honeypot="bot-field" class="calendar-event-form display-none"
57+
data-netlify="true" action="/">
58+
<h5 class="text-center custom-green-color-font bold-text">
59+
Community Event Details
60+
</h5>
61+
{% csrf_token %}
62+
{% for field in community_event_form %}
63+
<div class="row">
64+
<div class="input-field col s12">
65+
{% if field.name == 'user' %}
66+
<p><label for="{{ field.name }}">{{ field.label }}</label></p>
67+
{% else %}
68+
<label for="{{ field.name }}">{{ field.label }}</label>
69+
{% endif %}
70+
{{ field }}
71+
{% if field.help_text %}
72+
<i class="fa fa-info-circle" aria-hidden="true">{{ field.help_text }}</i>
73+
{% endif %}
74+
</div>
75+
</div>
76+
{% endfor %}
77+
<div class="validation-checkboxes">
78+
<p>
79+
<label>
80+
<input type="checkbox" required>
81+
<span>I am a member of {{ org.name }} developers group.</span>
82+
</label>
83+
</p>
84+
<p>
85+
<label>
86+
<input type="checkbox" required>
87+
<span>All of the above information provided by me has no false
88+
entries. If so, I am liable of getting blacklisted.</span>
89+
</label>
90+
</p>
91+
<p style="display: none">
92+
<label>
93+
<input type="checkbox" name="bot-field">
94+
<span>I am a bot</span>
95+
</label>
96+
</p>
97+
<p>
98+
<strong>
99+
Note: You will receive an email within 24 hrs, if any of the
100+
validation checks are not passed.
101+
</strong>
102+
</p>
103+
</div>
104+
<div class="apply-flex center-content submit-btn">
105+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
106+
</div>
107+
</form>

0 commit comments

Comments
 (0)