Skip to content

Commit 0c7825b

Browse files
committed
community/: Add a form for applying as a mentor
Closes #272
1 parent cc06a92 commit 0c7825b

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

0 commit comments

Comments
 (0)