Skip to content

Commit 3fd203b

Browse files
committed
better course feedback, make a photo avatar if no avatar
1 parent 7e487d6 commit 3fd203b

File tree

10 files changed

+43
-23
lines changed

10 files changed

+43
-23
lines changed

fixture/init/payments.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ require('payments');
33

44
exports.Transaction = [];
55
exports.TransactionLog = [];
6-
exports.Discount = [{
7-
code: "DISCOUNT",
8-
discount: 1
9-
}];
6+
exports.Discount = [];
107
exports.Order = [];
118

129
exports.OrderTemplate = [

handlers/courses/controller/groupFeedback.js renamed to handlers/courses/controller/groupFeedbackEdit.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,27 @@ exports.all = function*() {
5959
errors[key] = e.errors[key].message;
6060
}
6161

62-
this.body = this.render('groupFeedback/feedback', {
62+
this.body = this.render('feedback/edit', {
6363
errors: errors,
6464
form: courseFeedback
6565
});
6666

6767
return;
6868
}
6969

70+
// make the new picture user avatar
71+
if (courseFeedback.photo && !this.user.photo) {
72+
yield this.user.persist({
73+
photo: courseFeedback.photo
74+
});
75+
}
76+
77+
if (courseFeedback.isPublic) {
78+
this.addFlashMessage("success", "Ваш отзыв успешно сохранен. При желании, вы можете поделиться им в соц сетях.");
79+
} else {
80+
this.addFlashMessage("success", "Ваш отзыв успешно сохранен. Он будет виден только нам.");
81+
}
82+
7083
this.redirect(`/courses/feedback/${courseFeedback.number}`);
7184
return;
7285

@@ -75,7 +88,7 @@ exports.all = function*() {
7588

7689
this.locals.form = courseFeedback;
7790

78-
this.body = this.render('groupFeedback/feedback');
91+
this.body = this.render('feedback/edit');
7992
}
8093

8194
};

handlers/courses/controller/feedback.js renamed to handlers/courses/controller/groupFeedbackShow.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const mongoose = require('mongoose');
22
const countries = require('countries');
33
const CourseFeedback = require('../models/courseFeedback');
4+
const CourseGroup = require('../models/courseGroup');
45
const User = require('users').User;
56
const _ = require('lodash');
67

@@ -14,6 +15,8 @@ exports.get = function*() {
1415
this.throw(404);
1516
}
1617

18+
yield CourseGroup.populate(courseFeedback.group, 'course');
19+
1720
var authorOrAdmin = this.user.isAdmin || String(this.user._id) == String(courseFeedback.participant.user);
1821
this.locals.authorOrAdmin = authorOrAdmin;
1922

@@ -29,8 +32,11 @@ exports.get = function*() {
2932

3033
this.locals.countries = countries.all;
3134

35+
if (authorOrAdmin) {
36+
this.locals.editLink = `/courses/groups/${courseFeedback.group.slug}/feedback`;
37+
}
3238

33-
this.body = this.render('feedback/single');
39+
this.body = this.render('feedback/show');
3440

3541
};
3642

handlers/courses/controller/invite.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,9 @@ function* askParticipantDetails(invite) {
136136
var participant = new CourseParticipant(participantData);
137137

138138
try {
139+
139140
yield participant.persist();
141+
140142
} catch (e) {
141143
var errors = {};
142144
for (var key in e.errors) {
@@ -153,12 +155,18 @@ function* askParticipantDetails(invite) {
153155

154156
this.log.debug(participant.toObject(), "participant is accepted");
155157

158+
// make the new picture user avatar
159+
if (participant.photo && !this.user.photo) {
160+
yield this.user.persist({
161+
photo: participant.photo
162+
});
163+
}
164+
156165
yield* acceptParticipant.call(this, invite, participant);
157166

158167
// will show "welcome" cause the invite is accepted
159168
this.redirect('/courses/invite/' + invite.token);
160169

161-
162170
} else if (this.method == 'GET') {
163171

164172
this.body = this.render('invite/askParticipantDetails', {

handlers/courses/lib/paymentMethods.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const payments = require('payments');
22

33
var paymentMethods = {};
44

5-
var methodsEnabled = ['webmoney', 'yandexmoney', 'payanyway', 'paypal', 'interkassa', 'banksimple', 'invoice'];
5+
var methodsEnabled = [ 'paypal', 'webmoney', 'yandexmoney', 'payanyway', 'interkassa', 'banksimple', 'invoice'];
66

77
methodsEnabled.forEach(function(key) {
88
paymentMethods[key] = payments.methods[key].info;

handlers/courses/router.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ router.get('/groups/:groupBySlug/materials', mustBeParticipant, require('./contr
2020
// because the prefix /course/download must be constant for nginx to proxy *.zip to node
2121
router.get('/download/:groupBySlug/:filename', mustBeParticipant, require('./controller/groupMaterialsDownload').get);
2222

23-
router.all('/groups/:groupBySlug/feedback', mustBeParticipant, require('./controller/groupFeedback').all);
23+
router.all('/groups/:groupBySlug/feedback', mustBeParticipant, require('./controller/groupFeedbackEdit').all);
2424

25-
router.get('/feedback/:feedbackNumber', require('./controller/feedback').get);
25+
router.get('/feedback/:feedbackNumber', require('./controller/groupFeedbackShow').get);
2626

2727
router.patch('/participants', require('./controller/participants').patch);
2828

File renamed without changes.

handlers/courses/templates/feedback/single.jade renamed to handlers/courses/templates/feedback/show.jade

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,13 @@ block append variables
44

55
- var layout_header_class = "main__header_center"
66
- var layout_main_class = "main_width-limit"
7-
- var breadcrumbs = [{ title: 'JavaScript.ru', url: 'http://javascript.ru' }, { title: 'Учебник', url: '/' }]
7+
- var breadcrumbs = [{ title: 'JavaScript.ru', url: 'http://javascript.ru' }, { title: 'Учебник', url: '/' }, { title: 'Курсы', url: '/courses' }]
88
- var content_class = '_center'
99
- var siteToolbarCurrentSection = "courses"
10+
- var sitetoolbar = true
1011

1112
block content
1213

13-
//-
14-
+b(class="notification notification_message notification_success")
15-
+e.content Ваш отзыв успешно сохранен. При желании, вы можете поделиться им в соц сетях
16-
1714
+b.course-feedback._result
1815
+e.user
1916
+e.userpic
@@ -39,14 +36,13 @@ block content
3936
for raiting in [1,2,3,4,5]
4037
+e('i').star
4138

42-
// TODO: не рекомендует?
4339
if courseFeedback.recommend
44-
+e.name Рекомендует курс “Javascript, DOM, интерфейсы”
40+
+e.name Рекомендует #{group.course.title.replace(/./, function(match) { return match.toLowerCase(); })}
4541

4642
+e.body!= renderSimpledown(courseFeedback.content, {trusted: false})
4743

48-
if authorOrAdmin
49-
+e('a').edit(href="/courses/groups/#{courseFeedback.courseGroup.slug}/feedback") редактировать
44+
if editLink
45+
+e('a').edit(href=editLink) редактировать
5046
+e.share
5147
+b.share-icons
5248
+e('span').title Поделиться

handlers/markup/templates/blocks/payment-settings.jade

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ block append variables
1111
+e('option').option(value="RUR") RUR
1212
+e('span').small-note
1313
| Если у вас Paypal аккаунт в рублях, вы <br>
14-
| не сможете оплатить в другой валюте
14+
| сможете оплатить только в RUB.
1515

1616
if name == 'invoice'
1717
+e.item
@@ -36,4 +36,4 @@ block append variables
3636

3737
+e.item_hidden
3838
+e('label').label(for="pay-form-bank-details") Банковские реквизиты:
39-
+b('textarea').textarea-input.__textarea-bank#pay-form-bank-details(cols="30", rows="5")
39+
+b('textarea').textarea-input.__textarea-bank#pay-form-bank-details(cols="30", rows="5")

handlers/payments/common/templates/paypal-settings.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
+e('option').option(value="USD") USD
88
+e('option').option(value="EUR") EUR
99
+e('span').small-note
10-
| Если у вас Российский Paypal аккаунт, вы<br> не сможете оплатить в другой валюте.
10+
| Если у вас Российский Paypal аккаунт, вы<br> сможете оплатить только в RUB.

0 commit comments

Comments
 (0)