|
@@ -10,6 +10,10 @@ if (Meteor.isClient) {
|
|
|
images: Images.find({}, { sort: { createdOn: -1, rating: -1 }}),
|
|
|
image_id: function () {
|
|
|
return "rating-" + this._id;
|
|
|
+ },
|
|
|
+ getUser: function (userId) {
|
|
|
+ let user = Meteor.users.findOne({ _id: userId });
|
|
|
+ return user ? user.username : "anonymous";
|
|
|
}
|
|
|
});
|
|
|
|
|
@@ -55,12 +59,15 @@ if (Meteor.isClient) {
|
|
|
let img_alt = event.target.img_alt.value;
|
|
|
console.log("src: " + img_src + " alt: " + img_alt);
|
|
|
|
|
|
- Images.insert({
|
|
|
- img_src: img_src,
|
|
|
- img_alt: img_alt,
|
|
|
- createdOn: new Date()
|
|
|
- });
|
|
|
- $("#image_add_form").modal('show');
|
|
|
+ if (Meteor.user()) {
|
|
|
+ Images.insert({
|
|
|
+ img_src: img_src,
|
|
|
+ img_alt: img_alt,
|
|
|
+ createdOn: new Date(),
|
|
|
+ createdBy: Meteor.userId()
|
|
|
+ });
|
|
|
+ }
|
|
|
+ $("#image_add_form").modal("hide");
|
|
|
return false;
|
|
|
}
|
|
|
});
|