Skip to content

Commit cad4c4f

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

File tree

4 files changed

+92
-3
lines changed

4 files changed

+92
-3
lines changed

community/forms.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
from django import forms
44

5-
TODAY = datetime.now().today()
5+
from community.git import get_org_name
66

7+
TODAY = datetime.now().today()
8+
ORG_NAME = get_org_name()
79

810
class JoinCommunityForm(forms.Form):
911

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

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: 2 additions & 2 deletions
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');

templates/community_forms.html

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