From 149f0751f011355d7543d48e1028e18b7173452b 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 | 26 ++++++++++++++++ community/views.py | 10 +++++++ static/js/forms.js | 2 +- templates/community_forms.html | 54 ++++++++++++++++++++++++++++++++++ 4 files changed, 91 insertions(+), 1 deletion(-) diff --git a/community/forms.py b/community/forms.py index e75f05de..3f288cb0 100644 --- a/community/forms.py +++ b/community/forms.py @@ -2,7 +2,10 @@ from django import forms +from community.git import get_org_name + TODAY = datetime.now().today() +ORG_NAME = get_org_name() class JoinCommunityForm(forms.Form): @@ -192,3 +195,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 5cadc3d9..f4c0e224 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 b1d8c5e7..3ce22188 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); diff --git a/templates/community_forms.html b/templates/community_forms.html index 8c544e7d..a7325835 100644 --- a/templates/community_forms.html +++ b/templates/community_forms.html @@ -260,3 +260,57 @@
+ +