From cad4c4f8823638853e05ac5fa89f5f177e21f8e0 Mon Sep 17 00:00:00 2001 From: Keshav Garg Date: Thu, 1 Aug 2019 12:07:39 +0530 Subject: [PATCH] community/: Add a request form to assign issue Closes https://github.com/coala/community/issues/280 --- community/forms.py | 27 ++++++++++++++++- community/views.py | 10 +++++++ static/js/forms.js | 4 +-- templates/community_forms.html | 54 ++++++++++++++++++++++++++++++++++ 4 files changed, 92 insertions(+), 3 deletions(-) diff --git a/community/forms.py b/community/forms.py index e75f05de..05d9d1ac 100644 --- a/community/forms.py +++ b/community/forms.py @@ -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): @@ -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}) + ) diff --git a/community/views.py b/community/views.py index 2ab3b644..654c4bf6 100644 --- a/community/views.py +++ b/community/views.py @@ -18,6 +18,7 @@ CommunityEvent, OrganizationMentor, GSOCStudent, + AssignIssue ) from data.models import Team from gamification.models import Participant as GamificationParticipant @@ -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( @@ -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 diff --git a/static/js/forms.js b/static/js/forms.js index 2f5d2ed8..d6543060 100644 --- a/static/js/forms.js +++ b/static/js/forms.js @@ -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); @@ -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'); diff --git a/templates/community_forms.html b/templates/community_forms.html index 5e6046b8..58f4bf88 100644 --- a/templates/community_forms.html +++ b/templates/community_forms.html @@ -209,3 +209,57 @@
+ +