Exemple #1
0
def delete_model_JSON(request,model_klass, model_id):
    """
    Generic JSON view for model deletion.
    Returns a status indicator and the model JSONized.
    """
    model = get_object_or_404(model_klass, pk=model_id)
    model_dump = instance_to_dict(model)
    model.delete()
    return JSONResponse({'status': 'ok', 'object': model_dump})
Exemple #2
0
def delete_model_JSON(request, model_klass, model_id):
    """
    Generic JSON view for model deletion.
    Returns a status indicator and the model JSONized.
    """
    model = get_object_or_404(model_klass, pk=model_id)
    model_dump = instance_to_dict(model)
    model.delete()
    return JSONResponse({'status': 'ok', 'object': model_dump})
Exemple #3
0
 def to_dict(self, with_tags=False, **kwargs):
     d = instance_to_dict(self)
     if with_tags:
         d.update({'tags_by_category': self.tags_by_category()})
     return d
Exemple #4
0
 def tags_by_category(self):
     output = {}
     for tag in self.tags.all():
         append_to_key(output, tag.category.name, instance_to_dict(tag))
     return output
Exemple #5
0
 def to_dict(self):
     return instance_to_dict(self)
Exemple #6
0
 def to_dict(self, with_tags=False, **kwargs):
     d = instance_to_dict(self)
     d.pop('source_id')
     d['audiosource'] = self.source.to_dict()
     return d
Exemple #7
0
 def to_dict(self, with_tags=False, **kwargs):
     d = instance_to_dict(self)
     if with_tags:
         d.update({'tags_by_category': self.tags_by_category()})
     return d
Exemple #8
0
 def tags_by_category(self):
     output = {}
     for tag in self.tags.all():
         append_to_key(output, tag.category.name, instance_to_dict(tag))
     return output
Exemple #9
0
 def to_dict(self):
     return instance_to_dict(self)
Exemple #10
0
 def to_dict(self, with_tags=False, **kwargs):
     d = instance_to_dict(self)
     d.pop('source_id')
     d['audiosource'] = self.source.to_dict()
     return d