Dup subscriptions not allowed
This commit is contained in:
parent
621cf4e2ad
commit
e703057377
4 changed files with 13 additions and 3 deletions
|
|
@ -25,6 +25,10 @@ Meteor.methods({
|
|||
...doc
|
||||
};
|
||||
// console.log(newDoc);
|
||||
const already = Subscriptions.findOne(newDoc);
|
||||
if (already) {
|
||||
throw new Meteor.Error('500', 'on-already-subscribed');
|
||||
}
|
||||
return Subscriptions.insert(newDoc);
|
||||
} catch (exception) {
|
||||
console.error(exception);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@ class SubscriptionEditor extends React.Component {
|
|||
if (authenticated) {
|
||||
Meteor.call(methodToCall, doc, (error, subscriptionId) => {
|
||||
if (error) {
|
||||
Bert.alert(error.reason, 'danger');
|
||||
if (error.reason && error.reason.reason) {
|
||||
Bert.alert(t(error.reason.reason), 'danger');
|
||||
}
|
||||
} else {
|
||||
const confirmation = existingSubscription ? t('Zona actualizada') : t('Zona añadida');
|
||||
Bert.alert(confirmation, 'success');
|
||||
|
|
|
|||
|
|
@ -232,5 +232,7 @@
|
|||
"Estás subscrito a una zona muy grande":
|
||||
"You are subscribed to a very large area",
|
||||
"Lugar no encontrado":
|
||||
"Place not found"
|
||||
"Place not found",
|
||||
"on-already-subscribed":
|
||||
"Upppps: You have already subscribed to that zone before"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -319,5 +319,7 @@
|
|||
"Estás subscrito a una zona muy grande":
|
||||
"Estás subscrito a una zona muy grande",
|
||||
"Lugar no encontrado":
|
||||
"Lugar no encontrado"
|
||||
"Lugar no encontrado",
|
||||
"on-already-subscribed":
|
||||
"Upppps: Ya te habías suscrito a esa zona antes"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue