Renamed app to avoid confusion with django forms

This commit is contained in:
David Taylor
2015-08-05 19:00:19 +03:00
committed by Tom Price
parent eb41636ffc
commit f99e16f562
9 changed files with 82 additions and 5 deletions

View File

@@ -44,6 +44,7 @@ INSTALLED_APPS = (
'django.contrib.messages',
'django.contrib.staticfiles',
'RIGS',
'rigForms',
'debug_toolbar',
'registration',

View File

@@ -1,3 +0,0 @@
from django.shortcuts import render
# Create your views here.

View File

@@ -1,6 +1,6 @@
from django.contrib import admin
from forms import models
from rigForms import models
import reversion

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import RIGS.models
class Migration(migrations.Migration):
dependencies = [
('RIGS', '0023_auto_20150529_0048'),
]
operations = [
migrations.CreateModel(
name='Form',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('data', models.TextField(default=b'{}')),
('event', models.ForeignKey(related_name='forms', to='RIGS.Event')),
],
bases=(models.Model, RIGS.models.RevisionMixin),
),
migrations.CreateModel(
name='Schema',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('start_at', models.DateTimeField()),
('schema', models.TextField(default=b'{}')),
('layout', models.TextField(default=b'{}')),
('comment', models.CharField(max_length=255)),
],
options={
'ordering': ['-start_at'],
'get_latest_by': 'start_at',
},
bases=(models.Model, RIGS.models.RevisionMixin),
),
migrations.CreateModel(
name='Type',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=255)),
('description', models.CharField(max_length=255, null=True, blank=True)),
('active', models.BooleanField(default=True)),
],
bases=(models.Model, RIGS.models.RevisionMixin),
),
migrations.AddField(
model_name='schema',
name='schema_type',
field=models.ForeignKey(related_name='schemas', to='forms.Type'),
),
migrations.AddField(
model_name='form',
name='schema',
field=models.ForeignKey(related_name='forms', to='forms.Schema'),
),
]

View File

@@ -1,5 +1,5 @@
from django.test import TestCase
from forms import models
from rigForms import models
class FormModelsTestCase(TestCase):
def setUp(self):

20
rigForms/views.py Normal file
View File

@@ -0,0 +1,20 @@
from django.shortcuts import render
from django.views import generic
from rigForms import models
class FormCreate(generic.CreateView):
model = models.Form
fields = ['data']
"""
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"])
currentSchema = models.Schema.objects.current_schema(schemaType)
context["type"] = schemaType
context["schema"] = currentSchema
return context