place/event annotations always need a place/event object. set formated date on annotations
This commit is contained in:
parent
765cd51367
commit
40ee2a0860
4 changed files with 15 additions and 6 deletions
|
@ -197,10 +197,14 @@ class Annotation(models.Model):
|
||||||
qs = self.places.all()
|
qs = self.places.all()
|
||||||
if qs.count() > 0:
|
if qs.count() > 0:
|
||||||
j['place'] = qs[0].json(user=user)
|
j['place'] = qs[0].json(user=user)
|
||||||
|
else:
|
||||||
|
j['place'] = {}
|
||||||
elif l['type'] == 'event':
|
elif l['type'] == 'event':
|
||||||
qs = self.events.all()
|
qs = self.events.all()
|
||||||
if qs.count() > 0:
|
if qs.count() > 0:
|
||||||
j['event'] = qs[0].json(user=user)
|
j['event'] = qs[0].json(user=user)
|
||||||
|
else:
|
||||||
|
j['event'] = {}
|
||||||
|
|
||||||
if layer or (keys and 'layer' in keys):
|
if layer or (keys and 'layer' in keys):
|
||||||
j['layer'] = self.layer
|
j['layer'] = self.layer
|
||||||
|
|
|
@ -13,8 +13,9 @@ def update_matching_events(id):
|
||||||
for e in a.events.filter(defined=False).exclude(name=a.value):
|
for e in a.events.filter(defined=False).exclude(name=a.value):
|
||||||
if e.annotations.exclude(id=id).count() == 0:
|
if e.annotations.exclude(id=id).count() == 0:
|
||||||
e.delete()
|
e.delete()
|
||||||
if a.get_layer().get('type') == 'event' \
|
for e in a.events.all():
|
||||||
and a.events.count() == 0:
|
e.update_matches()
|
||||||
|
if a.get_layer().get('type') == 'event' and a.events.count() == 0:
|
||||||
a.events.add(Event.get_or_create(a.value))
|
a.events.add(Event.get_or_create(a.value))
|
||||||
for e in a.events.all():
|
for e in a.events.all():
|
||||||
e.update_matches()
|
e.update_matches()
|
||||||
|
@ -33,8 +34,9 @@ def update_matching_places(id):
|
||||||
for p in a.places.filter(defined=False).exclude(name=a.value):
|
for p in a.places.filter(defined=False).exclude(name=a.value):
|
||||||
if p.annotations.exclude(id=id).count() == 0:
|
if p.annotations.exclude(id=id).count() == 0:
|
||||||
p.delete()
|
p.delete()
|
||||||
if a.get_layer().get('type') == 'place' \
|
for p in a.places.all():
|
||||||
and a.places.count() == 0:
|
p.update_matches()
|
||||||
|
if a.get_layer().get('type') == 'place' and a.places.count() == 0:
|
||||||
a.places.add(Place.get_or_create(a.value))
|
a.places.add(Place.get_or_create(a.value))
|
||||||
for p in a.places.all():
|
for p in a.places.all():
|
||||||
p.update_matches()
|
p.update_matches()
|
||||||
|
|
|
@ -350,6 +350,8 @@ pandora.ui.item = function() {
|
||||||
Ox.Log('', 'editAnnotation', data);
|
Ox.Log('', 'editAnnotation', data);
|
||||||
function callback(result) {
|
function callback(result) {
|
||||||
Ox.Log('', 'editAnnotation result', result);
|
Ox.Log('', 'editAnnotation result', result);
|
||||||
|
result.data.date = Ox.formatDate(result.data.modified.substr(0, 10),
|
||||||
|
'%B %e, %Y');
|
||||||
pandora.$ui.editor.updateAnnotation(data.id, result.data);
|
pandora.$ui.editor.updateAnnotation(data.id, result.data);
|
||||||
};
|
};
|
||||||
if (data.id[0] == '_') {
|
if (data.id[0] == '_') {
|
||||||
|
|
|
@ -831,6 +831,7 @@ pandora.getVideoOptions = function(data) {
|
||||||
pandora.site.layers.forEach(function(layer, i) {
|
pandora.site.layers.forEach(function(layer, i) {
|
||||||
options.layers[i] = Ox.extend({}, layer, {
|
options.layers[i] = Ox.extend({}, layer, {
|
||||||
items: data.layers[layer.id].map(function(annotation) {
|
items: data.layers[layer.id].map(function(annotation) {
|
||||||
|
annotation.date = Ox.formatDate(annotation.modified.substr(0, 10), '%B %e, %Y');
|
||||||
annotation.duration = Math.abs(annotation.out - annotation['in']);
|
annotation.duration = Math.abs(annotation.out - annotation['in']);
|
||||||
annotation.editable = annotation.editable
|
annotation.editable = annotation.editable
|
||||||
|| annotation.user == pandora.user.username
|
|| annotation.user == pandora.user.username
|
||||||
|
|
Loading…
Reference in a new issue