Skip to content

Commit 78fc40c

Browse files
committed
community/: Add a request form to assign issue
Closes #280
1 parent 0743317 commit 78fc40c

File tree

4 files changed

+92
-2
lines changed

4 files changed

+92
-2
lines changed

Diff for: 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+
)

Diff for: 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

Diff for: static/js/forms.js

+2-2
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

@@ -86,7 +86,7 @@ $(document).ready(function () {
8686
display_form_or_error(mentor_students_form);
8787
});
8888

89-
$(':input').focusin(function () {
89+
$('.community-form :input').focusin(function () {
9090
if (is_user_authenticated===undefined &&
9191
authenticated_username===undefined) {
9292
$('.community-form').css('display', 'none');

Diff for: templates/community_forms.html

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

0 commit comments

Comments
 (0)