Skip to content

Commit

Permalink
community/: Add a request form to assign issue
Browse files Browse the repository at this point in the history
Closes #280
  • Loading branch information
KVGarg committed Aug 15, 2019
1 parent 6048e0e commit e6ec383
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
19 changes: 19 additions & 0 deletions community/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

from django import forms

from community.git import get_org_name

TODAY = datetime.now().today()
ORG_NAME = get_org_name()


class JoinCommunityForm(forms.Form):
Expand Down Expand Up @@ -192,3 +195,19 @@ class GSOCStudent(forms.Form):
label='Personal Image URL', required=False,
widget=forms.URLInput(attrs={'autocomplete': 'off'})
)


class AssignIssue(forms.Form):
user = forms.CharField(
max_length=50, label='GitHub Username',
widget=forms.TextInput(attrs={'autocomplete': 'off'})
)
hoster = forms.ChoiceField(
choices=[('github', 'GitHub'), ('gitlab', 'GitLab')], label='Hoster'
)
url = forms.URLField(
label='Issue URL',
help_text=f'For example, https://github.com/'
f'{ORG_NAME}/community/issues/1',
widget=forms.URLInput(attrs={'autocomplete': 'off'})
)
10 changes: 10 additions & 0 deletions community/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
CommunityEvent,
OrganizationMentor,
GSOCStudent,
AssignIssue
)
from data.models import Team
from gamification.models import Participant as GamificationParticipant
Expand Down Expand Up @@ -48,6 +49,14 @@ def initialize_org_context_details():
return org_details


def get_assign_issue_form_variables(context):
context['assign_issue_form'] = AssignIssue()
context['assign_issue_form_name'] = os.environ.get(
'ISSUES_ASSIGN_REQUEST_FORM_NAME', None
)
return context


def get_gsoc_student_form_variables(context):
context['gsoc_student_form'] = GSOCStudent()
context['gsoc_student_form_name'] = os.environ.get(
Expand Down Expand Up @@ -85,6 +94,7 @@ def get_all_community_forms(context):
context = get_community_event_form_variables(context)
context = get_community_mentor_form_variables(context)
context = get_gsoc_student_form_variables(context)
context = get_assign_issue_form_variables(context)
return context


Expand Down
2 changes: 1 addition & 1 deletion static/js/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $(document).ready(function () {
var is_user_authenticated = Cookies.get('authenticated');
var authenticated_username = Cookies.get('username');

var username_input = $('[name=user]');
var username_input = $('[name$=user]');
username_input.attr('value', authenticated_username || 'Anonymous User');
username_input.attr('disabled', true);

Expand Down
54 changes: 54 additions & 0 deletions templates/community_forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,57 @@ <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="{{ assign_issue_form_name }}" method="post"
netlify-honeypot="bot-field" class="get-issue-assigned-form display-none"
data-netlify="true" action="/">
<h5 class="text-center custom-green-color-font bold-text">
On which Issue you want to work?
</h5>
{% csrf_token %}
{% for field in assign_issue_form %}
<div class="row">
<div class="input-field col s12">
{% if field.name == 'user' or field.name == 'hoster' %}
<p>{{ field.label_tag }}</p>
{% elif field.name != 'requested_user' %}
{{ field.label_tag }}
{% endif %}
{{ 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 }} oragnization.</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 e6ec383

Please sign in to comment.