Skip to content

Commit

Permalink
communit/: Add a form for applying as a mentor
Browse files Browse the repository at this point in the history
Closes #272
  • Loading branch information
KVGarg committed Aug 2, 2019
1 parent c80fd0c commit 378e6f1
Show file tree
Hide file tree
Showing 3 changed files with 91 additions and 3 deletions.
19 changes: 19 additions & 0 deletions community/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from datetime import datetime

from django import forms

TODAY = datetime.now().today()


class JoinCommunityForm(forms.Form):

Expand Down Expand Up @@ -129,3 +133,18 @@ class CommunityEvent(forms.Form):
help_text='DateTime Format should be YYYY-MM-DD HH:MM:SS',
widget=forms.TextInput(attrs={'autocomplete': 'off'})
)


class OrganizationMentor(forms.Form):
user = forms.CharField(
max_length=50, label='GitHub Username',
widget=forms.TextInput(attrs={'autocomplete': 'off'})
)
year = forms.ChoiceField(
choices=[(TODAY.year, TODAY.year), (TODAY.year + 1, TODAY.year + 1)],
label='Mentoring Year', widget=forms.Select()
)
program = forms.ChoiceField(
choices=[('GSoC', 'Google Summer of Code'), ('GCI', 'Google Code-In')],
label='Mentoring Program'
)
25 changes: 22 additions & 3 deletions community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
get_org_name,
get_remote_url
)
from .forms import JoinCommunityForm, CommunityGoogleForm, CommunityEvent
from .forms import (
JoinCommunityForm,
CommunityGoogleForm,
CommunityEvent,
OrganizationMentor
)
from data.models import Team
from gamification.models import Participant as GamificationParticipant
from meta_review.models import Participant as MetaReviewer
Expand Down Expand Up @@ -42,6 +47,14 @@ def initialize_org_context_details():
return org_details


def get_community_mentor_form_variables(context):
context['organization_mentor_form'] = OrganizationMentor()
context['organization_mentor_form_name'] = os.environ.get(
'MENTOR_FORM_NAME', None
)
return context


def get_community_event_form_variables(context):
context['community_event_form'] = CommunityEvent()
context['community_event_form_name'] = os.environ.get(
Expand All @@ -58,12 +71,18 @@ def get_community_google_form_variables(context):
return context


def get_all_community_forms(context):
context = get_community_google_form_variables(context)
context = get_community_event_form_variables(context)
context = get_community_mentor_form_variables(context)
return context


def get_header_and_footer(context):
context['isTravis'] = Travis.TRAVIS
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)
context = get_all_community_forms(context)
print('Running on Travis: {}, build link: {}'.format(context['isTravis'],
context['travisLink']
))
Expand Down
50 changes: 50 additions & 0 deletions templates/community_forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,53 @@ <h5 class="text-center custom-green-color-font bold-text">
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
</div>
</form>

<form name="{{ organization_mentor_form_name }}" method="post"
netlify-honeypot="bot-field" class="mentor-students-form display-none"
data-netlify="true" action="/">
<h5 class="text-center custom-green-color-font bold-text">
Mentoring Program Details
</h5>
{% csrf_token %}
{% for field in organization_mentor_form %}
<div class="row">
<div class="input-field col s12">
<p><label for="{{ field.name }}">{{ field.label }}</label></p>
{{ field }}
{% if field.help_text %}
<i class="fa fa-info-circle" aria-hidden="true">{{ field.help_text }}</i>
{% endif %}
</div>
</div>
{% endfor %}
<div class="validation-checkboxes">
<p>
<label>
<input type="checkbox" required>
<span>I am a member of {{ org.name }} developers group.</span>
</label>
</p>
<p>
<label>
<input type="checkbox" required>
<span>All of the above information provided by me has no false
entries. If so, I am liable of getting blacklisted.</span>
</label>
</p>
<p style="display: none">
<label>
<input type="checkbox" name="bot-field">
<span>I am a bot</span>
</label>
</p>
<p>
<strong>
Note: You will receive an email within 24 hrs, if any of the
validation checks are not passed.
</strong>
</p>
</div>
<div class="apply-flex center-content submit-btn">
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
</div>
</form>

0 comments on commit 378e6f1

Please sign in to comment.