Skip to content

Commit a2a122d

Browse files
committed
community/: Add a feedback form
Closes coala#274
1 parent fb9f45c commit a2a122d

File tree

6 files changed

+133
-9
lines changed

6 files changed

+133
-9
lines changed

community/forms.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,18 @@ class NewcomerPromotion(forms.Form):
293293
max_length=50, label='GitHub Username',
294294
widget=forms.TextInput(attrs={'autocomplete': 'off', 'hidden': True})
295295
)
296+
297+
298+
class Feedback(forms.Form):
299+
username = forms.CharField(
300+
label='GitHub Username', required=False,
301+
widget=forms.TextInput(attrs={'autocomplete': 'off'})
302+
)
303+
feedback = forms.CharField(
304+
max_length=1000, label='What you want us to improve?',
305+
widget=forms.Textarea(attrs={'autocomplete': 'off'})
306+
)
307+
experience = forms.CharField(
308+
required=False,
309+
widget=forms.TextInput(attrs={'autocomplete': 'off', 'hidden': True})
310+
)

community/views.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
OrganizationMentor,
2020
GSOCStudent,
2121
AssignIssue,
22-
NewcomerPromotion
22+
NewcomerPromotion,
23+
Feedback
2324
)
2425
from data.models import Team
2526
from gamification.models import Participant as GamificationParticipant
@@ -50,6 +51,14 @@ def initialize_org_context_details():
5051
return org_details
5152

5253

54+
def get_feedback_form_variables(context):
55+
context['feedback_form'] = Feedback()
56+
context['feedback_form_name'] = os.environ.get(
57+
'FEEDBACK_FORM_NAME', None
58+
)
59+
return context
60+
61+
5362
def get_newcomer_promotion_form_variables(context):
5463
context['newcomer_promotion_form'] = NewcomerPromotion()
5564
context['newcomer_promotion_form_name'] = os.environ.get(
@@ -105,6 +114,7 @@ def get_all_community_forms(context):
105114
context = get_gsoc_student_form_variables(context)
106115
context = get_assign_issue_form_variables(context)
107116
context = get_newcomer_promotion_form_variables(context)
117+
context = get_feedback_form_variables(context)
108118
return context
109119

110120

static/css/main.css

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ body {
3838
justify-content: center;
3939
}
4040

41-
.community-form {
41+
.community-form,
42+
.feedback {
4243
position: absolute;
4344
width: 70%;
4445
min-width: 330px;
@@ -52,25 +53,31 @@ body {
5253
overflow-x: auto;
5354
}
5455

55-
.community-form form {
56+
.community-form form,
57+
.feedback form {
5658
padding-bottom: inherit;
5759

5860
}
59-
.community-form form label {
61+
.community-form form label,
62+
.feedback form label,
63+
.experience {
6064
font-weight: bold;
6165
font-size: 1.5rem;
6266
color: darkcyan;
6367
}
6468

65-
.community-form form p{
69+
.community-form form p,
70+
.feedback form p {
6671
margin: 0;
6772
}
6873

69-
.community-form form textarea{
74+
.community-form form textarea,
75+
.feedback form textarea {
7076
margin-top: 10px;
7177
}
7278

73-
.community-form form .row{
79+
.community-form form .row,
80+
.feedback form .row {
7481
margin-bottom: 0;
7582
}
7683

@@ -97,6 +104,17 @@ body {
97104
display: none;
98105
}
99106

107+
.feedback-icon {
108+
position: fixed;
109+
bottom: 2%;
110+
right: 1%;
111+
}
112+
113+
.feedback-comment {
114+
width: 80px;
115+
cursor: pointer;
116+
}
117+
100118
.form-popup,
101119
.form-submission-popup {
102120
width: 100%;
@@ -275,6 +293,11 @@ strong {
275293
text-align: center;
276294
}
277295

296+
.user-feeling-level i {
297+
font-size: 3rem;
298+
cursor: pointer;
299+
}
300+
278301
#user-dropdown li.user-profile,
279302
#user-dropdown li.user-logout {
280303
display: none;

static/js/forms.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,15 @@ $(document).ready(function () {
77
var get_issue_assigned_form_op = $('.get-issue-assigned-form-op');
88
var participated_in_gsoc_form_op = $('.participated-in-gsoc-form-op');
99
var mentor_students_form_op = $('.mentor-students-form-op');
10+
var feedback_form_op = $('.feedback-comment');
1011

1112
var community_google_form = $('.community-google-form');
1213
var newcomer_promotion_form = $('.newcomer-promotion-form');
1314
var calendar_event_form = $('.calendar-event-form');
1415
var get_issue_assigned_form = $('.get-issue-assigned-form');
1516
var participated_in_gsoc_form = $('.participated-in-gsoc-form');
1617
var mentor_students_form = $('.mentor-students-form');
18+
var feedback_form = $('.feedback');
1719

1820
var is_user_authenticated = Cookies.get('authenticated');
1921
var authenticated_username = Cookies.get('username');
@@ -23,7 +25,7 @@ $(document).ready(function () {
2325
username_input.attr('value', authenticated_username || 'Anonymous User');
2426
username_input.attr('disabled', true);
2527

26-
$('form').attr(
28+
$('.community-form form').attr(
2729
'action',window.location.pathname +
2830
'?form_submitted=True&form_type=community'
2931
);
@@ -87,6 +89,26 @@ $(document).ready(function () {
8789
display_form_or_error(mentor_students_form);
8890
});
8991

92+
feedback_form_op.on('click', function () {
93+
var top_offset = feedback_form_op.offset().top;
94+
feedback_form.css('top', (top_offset-440).toString()+'px');
95+
feedback_form.css('display', 'block');
96+
$('.user-feeling-level i').on('click', function () {
97+
var experience = $(this).attr('experience');
98+
$('input[name="experience"]').val(experience);
99+
$('.user-feeling-level i').css('color', 'black');
100+
if(experience==='Negative'){
101+
$(this).css('color', 'red');
102+
}
103+
else if(experience==='Neutral'){
104+
$(this).css('color', 'blue');
105+
}
106+
else {
107+
$(this).css('color', 'darkgreen');
108+
}
109+
})
110+
});
111+
90112
$('.community-form :input').focusin(function () {
91113
if (is_user_authenticated===undefined &&
92114
authenticated_username===undefined) {

static/js/main.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ $(document).ready(function(){
2222
' the validation checks are passed or not. If not, the email' +
2323
' will contain the validation errors. Correct them, if any';
2424
}
25+
else if(formType==='feedback'){
26+
message = 'Your valuable feedback has been received. Thanks for' +
27+
' providing feedback.'
28+
}
2529
$('.important-message').text(message);
2630
$('.form-submission-popup').css('display', 'block');
2731
}
@@ -124,12 +128,18 @@ $(document).ready(function(){
124128
$('.form-popup').css('display', 'block');
125129
});
126130

131+
$('.feedback form').attr(
132+
'action',window.location.pathname +
133+
'?form_submitted=True&form_type=feedback'
134+
);
135+
127136
$('.close-form').click(function () {
128137
$('.form-popup').css('display', 'none');
129138
$('.form-submission-popup').css('display', 'none');
130139
$('.oauth-error').css('display', 'none');
131140
$('.community-form').css('display', 'none');
132-
$('form').css('display', 'none');
141+
$('.feedback').css('display', 'none');
142+
$('.community-form form').css('display', 'none');
133143
});
134144

135145
logout_user_el.click(function () {

templates/base.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,50 @@ <h6>Enjoy Coding 'n' Learning</h6>
173173
{% include 'community_forms.html' %}
174174
</div>
175175

176+
<div class="feedback-icon">
177+
<img alt="feedback" class="feedback-comment"
178+
src="https://www.agcsoftware.com/wp-content/uploads//2017/06/feedback-icon.png">
179+
</div>
180+
181+
<div class="feedback display-none">
182+
<div class="apply-flex close-form">
183+
<i class="fa fa-times" aria-hidden="true"></i>
184+
</div>
185+
<form name="{{ feedback_form_name }}" method="post"
186+
netlify-honeypot="bot-field" class="feedback-form"
187+
data-netlify="true" action="/">
188+
<h5 class="text-center custom-green-color-font bold-text">
189+
Feedback
190+
</h5>
191+
{% csrf_token %}
192+
{% for field in feedback_form %}
193+
{% if field.name != 'experience' %}
194+
<div class="row">
195+
<div class="input-field col s12">
196+
{{ field.label_tag }}
197+
{{ field }}
198+
</div>
199+
</div>
200+
{% else %}
201+
{{ field }}
202+
{% endif %}
203+
{% endfor %}
204+
<div class="row">
205+
<div class="input-field col s12">
206+
<h6 class="experience">Feeling about {{ org.name }} organization?</h6>
207+
<div class="user-feeling-level apply-flex evenly-spread-content">
208+
<i class="fa fa-frown-o" experience="Negative" aria-hidden="true"></i>
209+
<i class="fa fa-meh-o" experience="Neutral" aria-hidden="true"></i>
210+
<i class="fa fa-smile-o" experience="Positive" aria-hidden="true"></i>
211+
</div>
212+
</div>
213+
</div>
214+
<div class="apply-flex center-content submit-btn">
215+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
216+
</div>
217+
</form>
218+
</div>
219+
176220
<footer class="page-footer">
177221
<div class="row">
178222
<div class="col m3 s12">

0 commit comments

Comments
 (0)