You've already forked code_examples_server
mirror of
https://github.com/AdaCore/code_examples_server.git
synced 2026-02-12 12:45:18 -08:00
Initial revision
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.pyc
|
||||
db.sqlite3
|
||||
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
6
app/admin.py
Normal file
6
app/admin.py
Normal 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
8
app/apps.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AppConfig(AppConfig):
|
||||
name = 'app'
|
||||
0
app/migrations/__init__.py
Normal file
0
app/migrations/__init__.py
Normal file
6
app/models.py
Normal file
6
app/models.py
Normal 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
6
app/tests.py
Normal 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
6
app/views.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
0
compile_server/__init__.py
Normal file
0
compile_server/__init__.py
Normal file
0
compile_server/app/__init__.py
Normal file
0
compile_server/app/__init__.py
Normal file
6
compile_server/app/admin.py
Normal file
6
compile_server/app/admin.py
Normal file
@@ -0,0 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
8
compile_server/app/apps.py
Normal file
8
compile_server/app/apps.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AppConfig(AppConfig):
|
||||
name = 'app'
|
||||
0
compile_server/app/management/__init__.py
Normal file
0
compile_server/app/management/__init__.py
Normal file
0
compile_server/app/management/commands/__init__.py
Normal file
0
compile_server/app/management/commands/__init__.py
Normal file
24
compile_server/app/management/commands/fill_examples.py
Normal file
24
compile_server/app/management/commands/fill_examples.py
Normal 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"
|
||||
23
compile_server/app/migrations/0001_initial.py
Normal file
23
compile_server/app/migrations/0001_initial.py
Normal 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()),
|
||||
],
|
||||
),
|
||||
]
|
||||
@@ -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()),
|
||||
],
|
||||
),
|
||||
]
|
||||
0
compile_server/app/migrations/__init__.py
Normal file
0
compile_server/app/migrations/__init__.py
Normal file
48
compile_server/app/models.py
Normal file
48
compile_server/app/models.py
Normal 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()
|
||||
31
compile_server/app/serializers.py
Normal file
31
compile_server/app/serializers.py
Normal 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
Reference in New Issue
Block a user