Beispiel #1
0
def delete_event(request, event_id):
    from curia import delete_object
    event = Event.objects.get(pk=event_id)
    check_access(request.user, event, command='change event')
    delete_object(event)
    
    #Change any children
    if not event.event_parent:
        event_children = event.event_children.all()
        for child in event_children:
            try:
                child.description = _("This event has been deleted by its creator.")
                child.save()
            except:
                pass            
  
    #If this is a copy, change answer to no.
    if event.event_parent:
        parent = event.event_parent
        reply = get_object_or_404(Reply, event=parent, user=request.user)
        reply.choice = 'N'
        reply.save()
    
    mark_labels_as_deleted(event, request.user)
  
    from django.core import serializers
    return HttpResponse(dumps(event_id, ensure_ascii=False), content_type="text/json; charset=UTF-8")
Beispiel #2
0
def delete_event(request, event_id):
    from curia import delete_object

    event = Event.objects.get(pk=event_id)
    check_access(request.user, event, command="change event")
    delete_object(event)

    # Change any children
    if not event.event_parent:
        event_children = event.event_children.all()
        for child in event_children:
            try:
                child.description = _("This event has been deleted by its creator.")
                child.save()
            except:
                pass

    # If this is a copy, change answer to no.
    if event.event_parent:
        parent = event.event_parent
        reply = get_object_or_404(Reply, event=parent, user=request.user)
        reply.choice = "N"
        reply.save()

    mark_labels_as_deleted(event, request.user)

    from django.core import serializers

    return HttpResponse(dumps(event_id, ensure_ascii=False), content_type="text/json; charset=UTF-8")
Beispiel #3
0
def delete_object(object):
    from curia.labels import mark_labels_as_deleted
    object.deleted = True
    object.deleted_by = get_current_user()
    object.deletion_time = datetime.now()
    object.save()

    mark_labels_as_deleted(object, get_current_user())
Beispiel #4
0
def delete_object(object):
    from curia.labels import mark_labels_as_deleted
    object.deleted = True
    object.deleted_by = get_current_user()
    object.deletion_time = datetime.now()
    object.save()

    mark_labels_as_deleted(object, get_current_user())
Beispiel #5
0
def delete_image(request, image_id):
    image = Image.objects.get(pk=image_id)
    check_access(request.user, image.sets.all()[0], command='view')
    delete_object(image)
    
    #If this was the representative, set another image as representative
    image_set = image.sets.all()[0]
    if image_set.representative_image == image:
        try:
            image_set.representative_image = Image.objects.filter(sets=image_set, deleted=False)[0]
        except:
            image_set.representative_image = None
    image_set.number_of_images -= 1
    image_set.save()
                        
    mark_labels_as_deleted(image, request.user)

    from django.utils.simplejson import dumps 
    return HttpResponse(dumps(image.id, ensure_ascii=False), content_type="text/json; charset=UTF-8")
Beispiel #6
0
def delete_image(request, image_id):
    image = Image.objects.get(pk=image_id)
    check_access(request.user, image.sets.all()[0], command='view')
    delete_object(image)

    #If this was the representative, set another image as representative
    image_set = image.sets.all()[0]
    if image_set.representative_image == image:
        try:
            image_set.representative_image = Image.objects.filter(
                sets=image_set, deleted=False)[0]
        except:
            image_set.representative_image = None
    image_set.number_of_images -= 1
    image_set.save()

    mark_labels_as_deleted(image, request.user)

    from django.utils.simplejson import dumps
    return HttpResponse(dumps(image.id, ensure_ascii=False),
                        content_type="text/json; charset=UTF-8")