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 2, 2019
1 parent 0743317 commit cad4c4f
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 3 deletions.
27 changes: 26 additions & 1 deletion community/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

from django import forms

TODAY = datetime.now().today()
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 +194,26 @@ 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'
)
repository_url = forms.URLField(
label='Repository URL',
help_text=f'For example, https://github.com/{ORG_NAME}/community/',
widget=forms.URLInput(attrs={'autocomplete': 'off'})
)
issue_number = forms.IntegerField(
label='Issue Number',
widget=forms.NumberInput(attrs={'autocomplete': 'off'})
)
requested_user = forms.CharField(
max_length=50, label='GitHub Username',
widget=forms.TextInput(attrs={'autocomplete': 'off', 'hidden': True})
)
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
4 changes: 2 additions & 2 deletions 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 Expand Up @@ -86,7 +86,7 @@ $(document).ready(function () {
display_form_or_error(mentor_students_form);
});

$(':input').focusin(function () {
$('.community-form :input').focusin(function () {
if (is_user_authenticated===undefined &&
authenticated_username===undefined) {
$('.community-form').css('display', 'none');
Expand Down
54 changes: 54 additions & 0 deletions templates/community_forms.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,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><label for="{{ field.name }}">{{ field.label }}</label></p>
{% elif field.name != 'requested_user' %}
<label for="{{ field.name }}">{{ field.label }}</label>
{% 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 cad4c4f

Please sign in to comment.