Skip to content

Commit fc94d30

Browse files
committed
communit/: Add a form for applying as a mentor
Closes coala#272
1 parent c80fd0c commit fc94d30

File tree

3 files changed

+91
-3
lines changed

3 files changed

+91
-3
lines changed

community/forms.py

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
from datetime import datetime
2+
13
from django import forms
24

5+
TODAY = datetime.now().today()
6+
37

48
class JoinCommunityForm(forms.Form):
59

@@ -129,3 +133,18 @@ class CommunityEvent(forms.Form):
129133
help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS',
130134
widget=forms.TextInput(attrs={'autocomplete': 'off'})
131135
)
136+
137+
138+
class OrganizationMentor(forms.Form):
139+
user = forms.CharField(
140+
max_length=50, label='GitHub Username',
141+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
142+
)
143+
year = forms.ChoiceField(
144+
choices=[(TODAY.year, TODAY.year),(TODAY.year + 1, TODAY.year + 1)],
145+
label='Mentoring Year', widget=forms.Select()
146+
)
147+
program = forms.ChoiceField(
148+
choices=[('GSoC', 'Google Summer of Code'), ('GCI', 'Google Code-In')],
149+
label='Mentoring Program'
150+
)

community/views.py

+22-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212
get_org_name,
1313
get_remote_url
1414
)
15-
from .forms import JoinCommunityForm, CommunityGoogleForm, CommunityEvent
15+
from .forms import (
16+
JoinCommunityForm,
17+
CommunityGoogleForm,
18+
CommunityEvent,
19+
OrganizationMentor
20+
)
1621
from data.models import Team
1722
from gamification.models import Participant as GamificationParticipant
1823
from meta_review.models import Participant as MetaReviewer
@@ -42,6 +47,14 @@ def initialize_org_context_details():
4247
return org_details
4348

4449

50+
def get_community_mentor_form_variables(context):
51+
context['organization_mentor_form'] = OrganizationMentor()
52+
context['organization_mentor_form_name'] = os.environ.get(
53+
'MENTOR_FORM_NAME', None
54+
)
55+
return context
56+
57+
4558
def get_community_event_form_variables(context):
4659
context['community_event_form'] = CommunityEvent()
4760
context['community_event_form_name'] = os.environ.get(
@@ -58,12 +71,18 @@ def get_community_google_form_variables(context):
5871
return context
5972

6073

74+
def get_all_community_forms(context):
75+
context = get_community_google_form_variables(context)
76+
context = get_community_event_form_variables(context)
77+
context = get_community_mentor_form_variables(context)
78+
return context
79+
80+
6181
def get_header_and_footer(context):
6282
context['isTravis'] = Travis.TRAVIS
6383
context['travisLink'] = Travis.TRAVIS_BUILD_WEB_URL
6484
context['org'] = initialize_org_context_details()
65-
context = get_community_google_form_variables(context)
66-
context = get_community_event_form_variables(context)
85+
context = get_all_community_forms(context)
6786
print('Running on Travis: {}, build link: {}'.format(context['isTravis'],
6887
context['travisLink']
6988
))

templates/community_forms.html

+50
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,53 @@ <h5 class="text-center custom-green-color-font bold-text">
105105
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
106106
</div>
107107
</form>
108+
109+
<form name="{{ organization_mentor_form_name }}" method="post"
110+
netlify-honeypot="bot-field" class="mentor-students-form display-none"
111+
data-netlify="true" action="/">
112+
<h5 class="text-center custom-green-color-font bold-text">
113+
Mentoring Program Details
114+
</h5>
115+
{% csrf_token %}
116+
{% for field in organization_mentor_form %}
117+
<div class="row">
118+
<div class="input-field col s12">
119+
<p><label for="{{ field.name }}">{{ field.label }}</label></p>
120+
{{ field }}
121+
{% if field.help_text %}
122+
<i class="fa fa-info-circle" aria-hidden="true">{{ field.help_text }}</i>
123+
{% endif %}
124+
</div>
125+
</div>
126+
{% endfor %}
127+
<div class="validation-checkboxes">
128+
<p>
129+
<label>
130+
<input type="checkbox" required>
131+
<span>I am a member of {{ org.name }} developers group.</span>
132+
</label>
133+
</p>
134+
<p>
135+
<label>
136+
<input type="checkbox" required>
137+
<span>All of the above information provided by me has no false
138+
entries. If so, I am liable of getting blacklisted.</span>
139+
</label>
140+
</p>
141+
<p style="display: none">
142+
<label>
143+
<input type="checkbox" name="bot-field">
144+
<span>I am a bot</span>
145+
</label>
146+
</p>
147+
<p>
148+
<strong>
149+
Note: You will receive an email within 24 hrs, if any of the
150+
validation checks are not passed.
151+
</strong>
152+
</p>
153+
</div>
154+
<div class="apply-flex center-content submit-btn">
155+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
156+
</div>
157+
</form>

0 commit comments

Comments
 (0)