Don't ask for the transformation order when one is being created.

This commit is contained in:
Roberto Rosario
2015-07-17 12:54:49 -04:00
parent a08377b86e
commit e7f626aba4
2 changed files with 4 additions and 2 deletions

View File

@@ -38,7 +38,9 @@ class Transformation(models.Model):
def save(self, *args, **kwargs):
if not self.order:
self.order = Transformation.objects.filter(content_type=self.content_type, object_id=self.object_id).aggregate(Max('order'))['order__max'] + 1
last_order = Transformation.objects.filter(content_type=self.content_type, object_id=self.object_id).aggregate(Max('order'))['order__max']
if last_order is not None:
self.order = last_order + 1
super(Transformation, self).save(*args, **kwargs)
class Meta:

View File

@@ -55,7 +55,7 @@ class TransformationDeleteView(SingleObjectDeleteView):
class TransformationCreateView(SingleObjectCreateView):
fields = ('name', 'arguments', 'order')
fields = ('name', 'arguments')
def dispatch(self, request, *args, **kwargs):
content_type = get_object_or_404(ContentType, app_label=self.kwargs['app_label'], model=self.kwargs['model'])