Skip to content

Commit 33cc52f

Browse files
author
David Lenton
committed
Merged in add-author-program-option (pull request auth0#23)
Add author program option
2 parents db465ad + 3a15cee commit 33cc52f

File tree

7 files changed

+39
-4
lines changed

7 files changed

+39
-4
lines changed

js/clprogram.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ var programcourse = window.programcourse || [];
166166
if (document.getElementById('start_program')) {
167167
program.start_program = document.getElementById('start_program').value;
168168
}
169+
if (document.getElementById('author')) {
170+
program.author = document.getElementById('author').value;
171+
if (program.author === '') program.author = null;
172+
}
169173
if (document.getElementById('cost')) {
170174
program.cost = document.getElementById('cost').value;
171175
if (program.cost === '') program.cost = null;
@@ -264,6 +268,7 @@ var programcourse = window.programcourse || [];
264268
if (p.restrict_course_next)
265269
document.getElementById('options-next-course').checked = 'checked';
266270
if (p.cost) document.getElementById('cost').value = p.cost;
271+
if (p.author) document.getElementById('author').value = p.author;
267272
if (p.terms) document.getElementById('cost-terms').checked = 'checked';
268273
if (p.status) {
269274
var subjectStatus = document.getElementById('status');

models/program.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class Program {
268268
options.pageParam =
269269
typeof options.pageParam !== 'undefined' ? options.pageParam : '/';
270270
const params = [this.appId];
271-
let query = 'SELECT module.id, image_url, name, description, count(module_subject.subject_id) as subject_count, owner, if (module_account.account_id is null, 0, 1) As added ';
271+
let query = 'SELECT module.id, image_url, name, description, count(module_subject.subject_id) as subject_count, author, owner, if (module_account.account_id is null, 0, 1) As added ';
272272
// if (options.userId) {
273273
// query += ', max(account_subject_statistics.last_accessed) as latest ';
274274
// params.push(options.userId);
@@ -278,7 +278,7 @@ class Program {
278278
let orderBy = 'name DESC';
279279
if (options.searchText) {
280280
query =
281-
'SELECT module.id, image_url, name, description, count(module_subject.subject_id) as subject_count, owner, if (module_account.account_id is null, 0, 1) As added FROM module LEFT JOIN module_account ON module.id = module_account.module_id INNER JOIN sites ON module.client_id = sites.client_id LEFT JOIN module_subject ON module.id = module_subject.module_id LEFT JOIN settings ON module.id = settings.home_program_id ';
281+
'SELECT module.id, image_url, name, description, count(module_subject.subject_id) as subject_count, author, owner, if (module_account.account_id is null, 0, 1) As added FROM module LEFT JOIN module_account ON module.id = module_account.module_id INNER JOIN sites ON module.client_id = sites.client_id LEFT JOIN module_subject ON module.id = module_subject.module_id LEFT JOIN settings ON module.id = settings.home_program_id ';
282282
where = 'WHERE module.client_id = ? AND settings.id IS NULL AND name LIKE ? ';
283283
params.push('%' + options.searchText + '%');
284284
}
@@ -1335,6 +1335,8 @@ class Program {
13351335
return done(err);
13361336
// CHANGED THIS
13371337
_this.owner = owner;
1338+
// Author supercedes owner
1339+
if (_this.author) _this.owner = _this.author;
13381340
if (_this.originator_id) {
13391341
subject.getOriginator(_this.originator_id, _this.appId, (err, user) => {
13401342
if (err)
@@ -1532,6 +1534,7 @@ class Program {
15321534
current_id: this.version_id,
15331535
restrict_next: this.restrict_next,
15341536
restrict_course_next: this.restrict_course_next,
1537+
author: this.author,
15351538
cost: this.cost,
15361539
terms: this.terms,
15371540
last_saved: new Date(),

mysql/database.mwb

1.03 KB
Binary file not shown.

public/js/clprogram.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ var programcourse = window.programcourse || [];
166166
if (document.getElementById('start_program')) {
167167
program.start_program = document.getElementById('start_program').value;
168168
}
169+
if (document.getElementById('author')) {
170+
program.author = document.getElementById('author').value;
171+
if (program.author === '') program.author = null;
172+
}
169173
if (document.getElementById('cost')) {
170174
program.cost = document.getElementById('cost').value;
171175
if (program.cost === '') program.cost = null;
@@ -264,6 +268,7 @@ var programcourse = window.programcourse || [];
264268
if (p.restrict_course_next)
265269
document.getElementById('options-next-course').checked = 'checked';
266270
if (p.cost) document.getElementById('cost').value = p.cost;
271+
if (p.author) document.getElementById('author').value = p.author;
267272
if (p.terms) document.getElementById('cost-terms').checked = 'checked';
268273
if (p.status) {
269274
var subjectStatus = document.getElementById('status');

routes/api/program.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ function processForDisplay(p) {
2828
p.image.title = p.name;
2929
}
3030
p.published = p.published_date;
31+
// Author supercedes owner
32+
if (p.author) p.owner = p.author;
3133
return p;
3234
}
3335

@@ -45,7 +47,8 @@ function setProgramProperties(prog, body) {
4547
prog.status = body.status;
4648
prog.restrict_next = body.restrict_next;
4749
prog.restrict_course_next = body.restrict_course_next;
48-
prog.cost = body.cost;
50+
prog.author = body.author;
51+
prog.cost = body.cost || null;
4952
prog.terms = body.terms;
5053
prog.list = body.list;
5154
return prog;

src/scss/editor.scss

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,7 @@ form {
566566
.complete,
567567
.next,
568568
.after,
569+
.author,
569570
.publishing,
570571
.sponsorship,
571572
.locales,
@@ -758,6 +759,16 @@ form {
758759
min-height: 2em;
759760
}
760761
}
762+
.author {
763+
// span.authorname {
764+
// float: left;
765+
// text-align: left;
766+
// position: relative;
767+
// }
768+
input[type='text'] {
769+
width: 15em;
770+
}
771+
}
761772
.cost {
762773
span.amount {
763774
float: left;

views/admin/program-view.pug

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,15 @@ block content
104104
p.terms
105105
input(type='checkbox', name='cost-terms', id='cost-terms')
106106
label.full.checkbox(for='cost-terms') I understand and agree that all payments are in Canadian dollars and that any payment will be a subject to a 15% administration fee and that all payments are subject to the terms set out in the agreement with Consolidated Learning Inc, and confirm that I am authorised to enter into this agreement.
107-
107+
.author
108+
h2 Author
109+
.help
110+
p You can specify an author if you want to override the default for this site
111+
div
112+
p
113+
label.full Author
114+
span.authorname
115+
input(id='author', name='author', type='text', maxlength='255')
108116
.publishing
109117
h2 Publish
110118
#info Saved

0 commit comments

Comments
 (0)