Skip to content

Commit 149f075

Browse files
committed
community/: Add a request form to assign issue
Closes #280
1 parent 85ec1e3 commit 149f075

File tree

4 files changed

+91
-1
lines changed

4 files changed

+91
-1
lines changed

community/forms.py

Lines changed: 26 additions & 0 deletions
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

Lines changed: 10 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,3 +260,57 @@ <h5 class="text-center custom-green-color-font bold-text">
260260
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
261261
</div>
262262
</form>
263+
264+
<form name="{{ assign_issue_form_name }}" method="post"
265+
netlify-honeypot="bot-field" class="get-issue-assigned-form display-none"
266+
data-netlify="true" action="/">
267+
<h5 class="text-center custom-green-color-font bold-text">
268+
On which Issue you want to work?
269+
</h5>
270+
{% csrf_token %}
271+
{% for field in assign_issue_form %}
272+
<div class="row">
273+
<div class="input-field col s12">
274+
{% if field.name == 'user' or field.name == 'hoster' %}
275+
<p>{{ field.label_tag }}</p>
276+
{% elif field.name != 'requested_user' %}
277+
{{ field.label_tag }}
278+
{% endif %}
279+
{{ field }}
280+
{% if field.help_text %}
281+
<i class="fa fa-info-circle" aria-hidden="true">{{ field.help_text }}</i>
282+
{% endif %}
283+
</div>
284+
</div>
285+
{% endfor %}
286+
<div class="validation-checkboxes">
287+
<p>
288+
<label>
289+
<input type="checkbox" required>
290+
<span>I am a member of {{ org.name }} oragnization.</span>
291+
</label>
292+
</p>
293+
<p>
294+
<label>
295+
<input type="checkbox" required>
296+
<span>All of the above information provided by me has no false
297+
entries. If so, I am liable of getting blacklisted.</span>
298+
</label>
299+
</p>
300+
<p style="display: none">
301+
<label>
302+
<input type="checkbox" name="bot-field">
303+
<span>I am a bot</span>
304+
</label>
305+
</p>
306+
<p>
307+
<strong>
308+
Note: You will receive an email within 24 hrs, if any of the
309+
validation checks are not passed.
310+
</strong>
311+
</p>
312+
</div>
313+
<div class="apply-flex center-content submit-btn">
314+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
315+
</div>
316+
</form>

0 commit comments

Comments
 (0)