mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-25 17:32:16 +00:00
Renamed app to avoid confusion with django forms
This commit is contained in:
@@ -44,6 +44,7 @@ INSTALLED_APPS = (
|
|||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
'RIGS',
|
'RIGS',
|
||||||
|
'rigForms',
|
||||||
|
|
||||||
'debug_toolbar',
|
'debug_toolbar',
|
||||||
'registration',
|
'registration',
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from forms import models
|
from rigForms import models
|
||||||
|
|
||||||
import reversion
|
import reversion
|
||||||
|
|
||||||
59
rigForms/migrations/0001_initial.py
Normal file
59
rigForms/migrations/0001_initial.py
Normal 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'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from forms import models
|
from rigForms import models
|
||||||
|
|
||||||
class FormModelsTestCase(TestCase):
|
class FormModelsTestCase(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
20
rigForms/views.py
Normal file
20
rigForms/views.py
Normal 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
|
||||||
Reference in New Issue
Block a user