Commit 4ed9571a authored by Marlon Georg Lindner's avatar Marlon Georg Lindner
Browse files

worked on mongodb collection

parent 917511d2
......@@ -13,6 +13,7 @@ import {UserPermissions} from "../../util/permissions";
import {ServerStyle} from "../../util/styles";
import {Utilities} from "../../util/utilities";
import {Cardsets} from "../subscriptions/cardsets.js";
import {publishCardsets} from "../subscriptions/"
Meteor.methods({
getSearchCategoriesResult: function (searchValue, filterType) {
......@@ -1010,7 +1011,17 @@ Meteor.methods({
}
}
},
requestToMakeVisible: function (cardset_id) {
requestToMakeVisible: function (cardset_id, requestedKind) {
check(cardset_id, String);
check(requestedKind, String);
},
deletePublishCardset: function (cardsetId) {
check(cardsetId, String);
if (!UserPermissions.gotBackendAccess()) {
throw new Meteor.Error("not-authorized");
} else {
publishCardsets.remove(cardsetId);
}
}
});
import {Mongo} from "meteor/mongo";
import {Meteor} from "meteor/meteor";
import {UserPermissions} from "../../util/permissions";
import {Cardsets} from "./cardsets";
import {ServerStyle} from "../../util/styles";
import {SimpleSchema} from "meteor/aldeed:simple-schema";
import {APIAccess} from "./cardsetApiAccess";
export const publishCardsets = new Mongo.Collection("publishCardsets");
if (Meteor.isServer) {
Meteor.publish("allPublishCardsets", function () {
if (this.userId && UserPermissions.gotBackendAccess()) {
let query = {};
if (!ServerStyle.gotSimplifiedNav()) {
query.shuffled = false;
}
return Cardsets.find(query);
} else {
this.ready();
}
});
Meteor.publish("publishCardsets", function () {
if (Roles.userIsInRole(this.userId, 'admin')) {
return APIAccess.find();
}
});
}
const PublishCardsetsSchema = new SimpleSchema({
cardsetId: {
type: String
},
requestedKind: {
type: String
}
});
Cardsets.attachSchema(PublishCardsetsSchema);
import './publicCardsets.html';
import {APIAccess} from "../../../api/subscriptions/cardsetApiAccess";
import {Cardsets} from "../../../api/subscriptions/cardsets";
import {publishCardsets} from "../../../api/subscriptions/publishCardsets";
import {Session} from "meteor/session";
Meteor.subscribe("public-cardsets");
Meteor.subscribe("publishCardsets");
Template.admin_publicCardsets.helpers({
publicCardsets: function () {
var tokenItems = [];
var apiAccessTokens = APIAccess.find({});
apiAccessTokens.forEach(function (token) {
var items = [];
var publishCardsetsItems = publishCardsets.find({});
publishCardsetsItems.forEach(function (token) {
var cardset = Cardsets.findOne({_id: token.cardset_id});
tokenItems.push({
items.push({
"_id": token._id,
"cardset_id": token.cardset_id,
"cardset": cardset.name,
"token": token.token
});
});
return tokenItems;
return items;
},
tableSettings: function () {
return {
......@@ -44,5 +45,13 @@ Template.admin_publicCardsets.helpers({
}
]
};
},
'(click) .confirmPublicCardsetsAdmin': function (event) {
event.preventDefault();
},
'(click) .declinePublicCardsetsAdmin': function (event) {
event.preventDefault();
let cardsetId = Session.get("cardsetId");
Meteor.call('deletePublishCardset', cardsetId);
}
});
......@@ -4,6 +4,7 @@ import {Session} from "meteor/session";
import {Template} from "meteor/templating";
import {Cardsets} from "../../../../api/subscriptions/cardsets";
import {BertAlertVisuals} from "../../../../util/bertAlertVisuals";
import {UserPermissions} from "../../../../util/permissions";
import "./publish.html";
Session.setDefault('activeKind', 'personal');
......@@ -86,14 +87,17 @@ Template.cardsetPublishForm.events({
}
//marks cardset to be reviewed, to make it public
if (kind === 'free' || kind === 'edu') {
visible = false;
kind = 'personal';
let text = "Kartensatz " + Session.get('activeCardset').name + " zur Überprüfung freigegeben";
let type = "Kartensatz-Freigabe";
let target = "lecturer";
Meteor.call("addNotification", target, type, text, Session.get('activeCardset')._id, "lecturer");
BertAlertVisuals.displayBertAlert(TAPi18n.__('cardset.request.alert'), 'success', 'growl-top-left');
Meteor.call('requestToMakeVisible', Session.get('activeCardset')._id);
if (!UserPermissions.isAdmin() || !UserPermissions.isLecturer()) {
visible = false;
let requestedKind = kind;
kind = 'personal';
let text = "Kartensatz " + Session.get('activeCardset').name + " zur Überprüfung freigegeben";
let type = "Kartensatz-Freigabe";
let target = "lecturer";
Meteor.call("addNotification", target, type, text, Session.get('activeCardset')._id, "lecturer");
BertAlertVisuals.displayBertAlert(TAPi18n.__('cardset.request.alert'), 'success', 'growl-top-left');
Meteor.call('requestToMakeVisible', Session.get('activeCardset')._id, requestedKind);
}
}
Meteor.call("publishCardset", Session.get('activeCardset')._id, kind, price, visible, function (err, res) {
if (res) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment