Skip to content

Commit 41f5fe8

Browse files
committed
community/: Add a feedback form
Closes coala#274
1 parent 7917dce commit 41f5fe8

File tree

6 files changed

+142
-15
lines changed

6 files changed

+142
-15
lines changed

community/forms.py

+15
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='Feedback',
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

+11-1
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

+29-6
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: fixed;
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%;
@@ -276,6 +294,11 @@ strong {
276294
text-align: center;
277295
}
278296

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

static/js/forms.js

+25
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');
@@ -28,6 +30,11 @@ $(document).ready(function () {
2830
'?form_submitted=True&form_type=community'
2931
);
3032

33+
$('.feedback-form').attr(
34+
'action',window.location.pathname +
35+
'?form_submitted=True&form_type=feedback'
36+
);
37+
3138
$.getJSON("/static/contributors-data.json", function (data) {
3239
var contributor_data = data[authenticated_username];
3340
var teams = contributor_data.teams;
@@ -87,6 +94,24 @@ $(document).ready(function () {
8794
display_form_or_error(mentor_students_form);
8895
});
8996

97+
feedback_form_op.on('click', function () {
98+
feedback_form.css('display', 'block');
99+
$('.user-feeling-level i').on('click', function () {
100+
var experience = $(this).attr('experience');
101+
$('input[name="experience"]').val(experience);
102+
$('.user-feeling-level i').css('color', 'black');
103+
if(experience==='Negative'){
104+
$(this).css('color', 'red');
105+
}
106+
else if(experience==='Neutral'){
107+
$(this).css('color', 'blue');
108+
}
109+
else {
110+
$(this).css('color', 'darkgreen');
111+
}
112+
});
113+
});
114+
90115
$('.community-form :input').focusin(function () {
91116
if (is_user_authenticated===undefined &&
92117
authenticated_username===undefined) {

static/js/main.js

+10
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ $(document).ready(function(){
2323
' the validation checks are passed or not. If not, the email' +
2424
' will contain the validation errors. Correct them, if any';
2525
}
26+
else if(formType==='feedback'){
27+
message = 'Your valuable feedback has been received. Thanks for' +
28+
' providing feedback.';
29+
}
2630
$('.important-message').text(message);
2731
$('.form-submission-popup').css('display', 'block');
2832
}
@@ -123,11 +127,17 @@ $(document).ready(function(){
123127
$('.form-popup').css('display', 'block');
124128
});
125129

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

templates/base.html

+52-8
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,61 @@ <h6>Enjoy Coding 'n' Learning</h6>
158158
</div>
159159
</div>
160160

161-
<div class="main-content">
162-
{% block main-content %}
163-
{% endblock %}
161+
<div class="feedback display-none">
162+
<div class="apply-flex close-form">
163+
<i class="fa fa-times" aria-hidden="true"></i>
164164
</div>
165-
166-
<div class="community-form apply-flex center-content display-none">
167-
<div class="apply-flex close-form">
168-
<i class="fa fa-times" aria-hidden="true"></i>
165+
<form name="{{ feedback_form_name }}" method="post"
166+
netlify-honeypot="bot-field" class="feedback-form"
167+
data-netlify="true" action="/">
168+
<h5 class="text-center custom-green-color-font bold-text">
169+
Feedback Form
170+
</h5>
171+
{% csrf_token %}
172+
{% for field in feedback_form %}
173+
{% if field.name != 'experience' %}
174+
<div class="row">
175+
<div class="input-field col s12">
176+
{{ field.label_tag }}
177+
{{ field }}
178+
</div>
179+
</div>
180+
{% else %}
181+
{{ field }}
182+
{% endif %}
183+
{% endfor %}
184+
<div class="row">
185+
<div class="input-field col s12">
186+
<h6 class="experience">Feeling about {{ org.name }} organization?</h6>
187+
<div class="user-feeling-level apply-flex evenly-spread-content">
188+
<i class="fa fa-frown-o" experience="Negative" aria-hidden="true"></i>
189+
<i class="fa fa-meh-o" experience="Neutral" aria-hidden="true"></i>
190+
<i class="fa fa-smile-o" experience="Positive" aria-hidden="true"></i>
191+
</div>
192+
</div>
193+
</div>
194+
<div class="apply-flex center-content submit-btn">
195+
<input class="waves-effect waves-light btn-large large-font" type="submit" value="Submit">
169196
</div>
170-
{% include 'community_forms.html' %}
197+
</form>
198+
</div>
199+
200+
<div class="main-content">
201+
{% block main-content %}
202+
{% endblock %}
203+
</div>
204+
205+
<div class="community-form apply-flex center-content display-none">
206+
<div class="apply-flex close-form">
207+
<i class="fa fa-times" aria-hidden="true"></i>
171208
</div>
209+
{% include 'community_forms.html' %}
210+
</div>
211+
212+
<div class="feedback-icon">
213+
<img alt="feedback" class="feedback-comment"
214+
src="//www.agcsoftware.com/wp-content/uploads//2017/06/feedback-icon.png">
215+
</div>
172216

173217
<footer class="page-footer">
174218
<div class="row">

0 commit comments

Comments
 (0)