Added view, doesn't yet submit

This commit is contained in:
David Taylor
2015-08-05 22:08:00 +03:00
committed by Tom Price
parent f99e16f562
commit 7a0746d1a4
12 changed files with 1165 additions and 6 deletions

View File

@@ -2,6 +2,8 @@ from django.shortcuts import render
from django.views import generic
from rigForms import models
from django.shortcuts import get_object_or_404
class FormCreate(generic.CreateView):
model = models.Form
fields = ['data']
@@ -10,11 +12,13 @@ class FormCreate(generic.CreateView):
Expects kwarg "type_pk" to contain PK of required type
"""
def get_context_data(self, **kwargs):
context = super(FormCreate, self).get_context_data(**kwargs)
schemaType = get_object_or_404(models.Type,kwargs["type_pk"])
context = super(FormCreate, self).get_context_data()
schemaType = get_object_or_404(models.Type, pk=self.kwargs['type_pk'])
currentSchema = models.Schema.objects.current_schema(schemaType)
context["type"] = schemaType
context["schema"] = currentSchema
context["object"] = {
"schema": currentSchema,
"data": "{}"
}
return context