Skip to content

Commit e7b9bf1

Browse files
committed
community/: Add a request form to assign issue
Closes #280
1 parent 50e3a57 commit e7b9bf1

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

community/forms.py

+26
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
from django import forms
44

5+
from community.git import get_org_name
6+
57
TODAY = datetime.now().today()
8+
ORG_NAME = get_org_name()
69

710

811
class JoinCommunityForm(forms.Form):
@@ -192,3 +195,26 @@ class GSOCStudent(forms.Form):
192195
label='Personal Image URL', required=False,
193196
widget=forms.URLInput(attrs={'autocomplete': 'off'})
194197
)
198+
199+
200+
class AssignIssue(forms.Form):
201+
user = forms.CharField(
202+
max_length=50, label='GitHub Username',
203+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
204+
)
205+
hoster = forms.ChoiceField(
206+
choices=[('github', 'GitHub'), ('gitlab', 'GitLab')], label='Hoster'
207+
)
208+
repository_url = forms.URLField(
209+
label='Repository URL',
210+
help_text=f'For example, https://github.com/{ORG_NAME}/community/',
211+
widget=forms.URLInput(attrs={'autocomplete': 'off'})
212+
)
213+
issue_number = forms.IntegerField(
214+
label='Issue Number',
215+
widget=forms.NumberInput(attrs={'autocomplete': 'off'})
216+
)
217+
requested_user = forms.CharField(
218+
max_length=50, label='GitHub Username',
219+
widget=forms.TextInput(attrs={'autocomplete': 'off', 'hidden': True})
220+
)

community/views.py

+10
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
CommunityEvent,
1919
OrganizationMentor,
2020
GSOCStudent,
21+
AssignIssue
2122
)
2223
from data.models import Team
2324
from gamification.models import Participant as GamificationParticipant
@@ -48,6 +49,14 @@ def initialize_org_context_details():
4849
return org_details
4950

5051

52+
def get_assign_issue_form_variables(context):
53+
context['assign_issue_form'] = AssignIssue()
54+
context['assign_issue_form_name'] = os.environ.get(
55+
'ISSUES_ASSIGN_REQUEST_FORM_NAME', None
56+
)
57+
return context
58+
59+
5160
def get_gsoc_student_form_variables(context):
5261
context['gsoc_student_form'] = GSOCStudent()
5362
context['gsoc_student_form_name'] = os.environ.get(
@@ -85,6 +94,7 @@ def get_all_community_forms(context):
8594
context = get_community_event_form_variables(context)
8695
context = get_community_mentor_form_variables(context)
8796
context = get_gsoc_student_form_variables(context)
97+
context = get_assign_issue_form_variables(context)
8898
return context
8999

90100

static/js/forms.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $(document).ready(function () {
1818
var is_user_authenticated = Cookies.get('authenticated');
1919
var authenticated_username = Cookies.get('username');
2020

21-
var username_input = $('[name=user]');
21+
var username_input = $('[name$=user]');
2222
username_input.attr('value', authenticated_username || 'Anonymous User');
2323
username_input.attr('disabled', true);
2424

templates/community_forms.html

+54
Original file line numberDiff line numberDiff line change
@@ -210,3 +210,57 @@ <h5 class="text-center custom-green-color-font bold-text">
210210
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
211211
</div>
212212
</form>
213+
214+
<form name="{{ assign_issue_form_name }}" method="post"
215+
netlify-honeypot="bot-field" class="get-issue-assigned-form display-none"
216+
data-netlify="true" action="/">
217+
<h5 class="text-center custom-green-color-font bold-text">
218+
On which Issue you want to work?
219+
</h5>
220+
{% csrf_token %}
221+
{% for field in assign_issue_form %}
222+
<div class="row">
223+
<div class="input-field col s12">
224+
{% if field.name == 'user' or field.name == 'hoster' %}
225+
<p>{{ field.label_tag }}</p>
226+
{% elif field.name != 'requested_user' %}
227+
{{ field.label_tag }}
228+
{% endif %}
229+
{{ field }}
230+
{% if field.help_text %}
231+
<i class="fa fa-info-circle" aria-hidden="true">{{ field.help_text }}</i>
232+
{% endif %}
233+
</div>
234+
</div>
235+
{% endfor %}
236+
<div class="validation-checkboxes">
237+
<p>
238+
<label>
239+
<input type="checkbox" required>
240+
<span>I am a member of {{ org.name }} oragnization.</span>
241+
</label>
242+
</p>
243+
<p>
244+
<label>
245+
<input type="checkbox" required>
246+
<span>All of the above information provided by me has no false
247+
entries. If so, I am liable of getting blacklisted.</span>
248+
</label>
249+
</p>
250+
<p style="display: none">
251+
<label>
252+
<input type="checkbox" name="bot-field">
253+
<span>I am a bot</span>
254+
</label>
255+
</p>
256+
<p>
257+
<strong>
258+
Note: You will receive an email within 24 hrs, if any of the
259+
validation checks are not passed.
260+
</strong>
261+
</p>
262+
</div>
263+
<div class="apply-flex center-content submit-btn">
264+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
265+
</div>
266+
</form>

0 commit comments

Comments
 (0)