Initial revision

This commit is contained in:
Nicolas Setton
2017-05-06 22:38:32 -04:00
parent 28b773db59
commit 048668da5a
28 changed files with 521 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*.pyc
db.sqlite3

0
app/__init__.py Normal file
View File

6
app/admin.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.

8
app/apps.py Normal file
View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'

View File

6
app/models.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.

6
app/tests.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.test import TestCase
# Create your tests here.

6
app/views.py Normal file
View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.shortcuts import render
# Create your views here.

View File

View File

View File

@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.contrib import admin
# Register your models here.

View File

@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.apps import AppConfig
class AppConfig(AppConfig):
name = 'app'

View File

@@ -0,0 +1,24 @@
# The manage.py command to enter examples in the database.
# This is meant to be used by the administrators of the project only.
import os
from django.core.management.base import BaseCommand
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('--remove_all', const=True, default=False,
action='store_const',
help='remove all examples from the database')
parser.add_argument('--dirs', nargs='+', type=str,
help='add the examples found in the given dirs')
def handle(self, *args, **options):
if 'remove_all' in
#where = options['add_dir']
#if not os.path.isdir(where):
# print "Pass a directory to --dir"

View File

@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-05 17:06
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Program',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('code', models.TextField()),
],
),
]

View File

@@ -0,0 +1,39 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-05-06 01:37
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Example',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.TextField(unique=True)),
('description', models.TextField()),
],
),
migrations.CreateModel(
name='Resource',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.TextField()),
('contents', models.TextField()),
],
),
migrations.CreateModel(
name='ToolOutput',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('status', models.IntegerField()),
('output', models.TextField()),
],
),
]

View File

@@ -0,0 +1,48 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models
# Create your models here.
class Program(models.Model):
"""That's a program for ya!"""
# The code
code = models.TextField()
class ToolOutput(models.Model):
"""The result on running a tool on a program"""
# The exit code
status = models.IntegerField()
# The complete raw output
output = models.TextField()
class Resource(models.Model):
"""This represents a file or a directory.
"""
# Base name of the resource
name = models.TextField()
# The contents of the resource
contents = models.TextField()
# TODO: if necessary (not sure it is) we can add
# fields to represent a hierarchy of resources.
class Example(models.Model):
"""One example to present to the user.
"""
# The unique name of the example
name = models.TextField(unique=True)
# A description
description = models.TextField()

View File

@@ -0,0 +1,31 @@
from django.contrib.auth.models import User, Group
from rest_framework import serializers
from compile_server.app.models import Program
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
class GroupSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Group
fields = ('url', 'name')
class ProgramSerializer(serializers.Serializer):
class Meta:
model = Program
fields = ('code')
code = serializers.CharField(style={'base_template': 'textarea.html'})
def create(self, validated_data):
return Snippet.objects.create(**validated_data)
def update(self, instance, validated_data):
instance.code = validated_data.get('code', instance.code)
instance.save() # do we actually want to save programs?
return instance

Some files were not shown because too many files have changed in this diff Show More