mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-20 12:20:18 -04:00
git methods
This commit is contained in:
parent
e2997a6652
commit
a12185aa2e
38
CLI/git.py
38
CLI/git.py
|
@ -1,38 +0,0 @@
|
||||||
import subprocess
|
|
||||||
import os
|
|
||||||
|
|
||||||
#students
|
|
||||||
def initialize(repo, subject):
|
|
||||||
process = subprocess.Popen(['git', 'clone', repo], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
|
||||||
output = process.communicate()
|
|
||||||
dirname = repo[repo.rindex('/')+1:repo.index(".git")]
|
|
||||||
os.rename(dirname, subject)
|
|
||||||
#print(output)
|
|
||||||
|
|
||||||
#Teachers
|
|
||||||
|
|
||||||
#make student repo by student id
|
|
||||||
def addStudent(stid, teacher):
|
|
||||||
os.mkdir(stid)
|
|
||||||
os.chdir(os.getcwd() + "/" + stid)
|
|
||||||
process = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
|
||||||
process.communicate()
|
|
||||||
process = subprocess.Popen(['git', 'add', '.'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
|
||||||
process.communicate()
|
|
||||||
process = subprocess.Popen(['git', 'commit', '-m', "First Commit"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
|
||||||
process.communicate()
|
|
||||||
|
|
||||||
def addStudents(filename):
|
|
||||||
print(filename)
|
|
||||||
|
|
||||||
def addAsignment(name):
|
|
||||||
print(name)
|
|
||||||
|
|
||||||
def updateAssignment(name):
|
|
||||||
print(name)
|
|
||||||
|
|
||||||
def comment(filename, text):
|
|
||||||
print(text)
|
|
||||||
|
|
||||||
|
|
||||||
initialize("https://github.com/therealraffi/1579460.git", "Math1")
|
|
95
CLI/s-git.py
Normal file
95
CLI/s-git.py
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
#git clone student directory ==> <student-id>/classes/assignments
|
||||||
|
def initStudent(ion_user):
|
||||||
|
#check if git has already been initialized
|
||||||
|
if(os.path.exists(str(ion_user) +"/" + ".git")):
|
||||||
|
print("Already synced to: " + str(ion_user))
|
||||||
|
return
|
||||||
|
|
||||||
|
#get student repo from API
|
||||||
|
URL = "http://127.0.0.1:8000/students/" + ion_user + "/"
|
||||||
|
r = requests.get(url = URL, auth=('student','_$YFE#34.9_37jr'))
|
||||||
|
if(r.status_code == 200):
|
||||||
|
data = r.json()
|
||||||
|
repo = data['repo']
|
||||||
|
classes = data['classes']
|
||||||
|
print(data)
|
||||||
|
#git clone repo
|
||||||
|
process = subprocess.Popen(['git', 'clone', repo], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
|
||||||
|
# make classes directory
|
||||||
|
for c in classes:
|
||||||
|
cpath = str(ion_user) + "/" + c['name']
|
||||||
|
if(os.path.exists(cpath)):
|
||||||
|
print(cpath + " already exists...")
|
||||||
|
else:
|
||||||
|
os.mkdir(str(ion_user) + "/" + c['name'])
|
||||||
|
|
||||||
|
#make assignments directory
|
||||||
|
for a in c['assignments']:
|
||||||
|
path = str(ion_user) + "/" + c['name'] + "/" + a['name']
|
||||||
|
print(path)
|
||||||
|
if(os.path.exists("/" +path)):
|
||||||
|
print(path + " already exists...")
|
||||||
|
else:
|
||||||
|
os.mkdir(str(ion_user) + "/" + c['name'] + "/" + a['name'])
|
||||||
|
|
||||||
|
#push to remote repo
|
||||||
|
os.chdir(ion_user)
|
||||||
|
process = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'add', '.'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'commit', '-m', "First Commit"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'push', '-u', 'origin','master'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
|
||||||
|
elif(r.status_code == 404):
|
||||||
|
print("Make new account!")
|
||||||
|
elif(r.status_code == 403):
|
||||||
|
print("Invalid username/password")
|
||||||
|
else:
|
||||||
|
print(r.status_code)
|
||||||
|
|
||||||
|
#Teachers
|
||||||
|
|
||||||
|
#make student repo by student id
|
||||||
|
def addStudent(stid, teacher):
|
||||||
|
os.mkdir(stid)
|
||||||
|
os.chdir(os.getcwd() + "/" + stid)
|
||||||
|
process = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
process = subprocess.Popen(['git', 'add', '.'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
process = subprocess.Popen(['git', 'commit', '-m', "First Commit"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
|
||||||
|
def addStudents(filename):
|
||||||
|
print(filename)
|
||||||
|
|
||||||
|
def addAsignment(name):
|
||||||
|
print(name)
|
||||||
|
|
||||||
|
def updateAssignment(name):
|
||||||
|
print(name)
|
||||||
|
|
||||||
|
def comment(filename, text):
|
||||||
|
print(text)
|
||||||
|
|
||||||
|
initStudent("2022rkhondak")
|
||||||
|
|
||||||
|
os.chdir("2022rkhondak")
|
||||||
|
process = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'add', '.'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'commit', '-m', "First Commit"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
||||||
|
process = subprocess.Popen(['git', 'push', '-u', 'origin','master'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.wait()
|
67
CLI/t-git.py
Normal file
67
CLI/t-git.py
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
|
#git clone student directory ==> <student-id>/classes/assignments
|
||||||
|
def initTeacher(student_id):
|
||||||
|
#check if git has already been initialized
|
||||||
|
if(os.path.exists(str(student_id) +"/" + ".git")):
|
||||||
|
print("Already synced to: " + str(student_id))
|
||||||
|
return
|
||||||
|
|
||||||
|
#get student repo from API
|
||||||
|
URL = "http://127.0.0.1:8000/students/" + str(student_id) + "/"
|
||||||
|
r = requests.get(url = URL, auth=('student','_$YFE#34.9_37jr'))
|
||||||
|
data = r.json()
|
||||||
|
repo = data['repo']
|
||||||
|
classes = data['classes']
|
||||||
|
print(classes)
|
||||||
|
#git clone repo
|
||||||
|
process = subprocess.Popen(['git', 'clone', repo], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
|
||||||
|
#make classes directory
|
||||||
|
for c in classes:
|
||||||
|
cpath = str(student_id) + "/" + c['name']
|
||||||
|
if(os.path.exists(cpath)):
|
||||||
|
print(cpath + " already exists...")
|
||||||
|
else:
|
||||||
|
os.mkdir(str(student_id) + "/" + c['name'])
|
||||||
|
|
||||||
|
#make assignments directory
|
||||||
|
for a in c['assignments']:
|
||||||
|
path = str(student_id) + "/" + c['name'] + "/" + a['name']
|
||||||
|
print(path)
|
||||||
|
if(os.path.exists("/" +path)):
|
||||||
|
print(path + " already exists...")
|
||||||
|
else:
|
||||||
|
os.mkdir(str(student_id) + "/" + c['name'] + "/" + a['name'])
|
||||||
|
|
||||||
|
#Teachers
|
||||||
|
|
||||||
|
#make student repo by student id
|
||||||
|
def addStudent(stid, teacher):
|
||||||
|
os.mkdir(stid)
|
||||||
|
os.chdir(os.getcwd() + "/" + stid)
|
||||||
|
process = subprocess.Popen(['git', 'init'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
process = subprocess.Popen(['git', 'add', '.'], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
process = subprocess.Popen(['git', 'commit', '-m', "First Commit"], stdout=subprocess.PIPE,stderr=subprocess.PIPE)
|
||||||
|
process.communicate()
|
||||||
|
|
||||||
|
def addStudents(filename):
|
||||||
|
print(filename)
|
||||||
|
|
||||||
|
def addAsignment(name):
|
||||||
|
print(name)
|
||||||
|
|
||||||
|
def updateAssignment(name):
|
||||||
|
print(name)
|
||||||
|
|
||||||
|
def comment(filename, text):
|
||||||
|
print(text)
|
||||||
|
|
||||||
|
|
||||||
|
initStudent(1579460)
|
|
@ -1,38 +1,63 @@
|
||||||
from api.models import Assignment, Student, Classes, Teacher
|
from api.models import Assignment, Student, Classes, Teacher, DefFiles
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
#students
|
f1 = DefFiles(
|
||||||
raffu = Student(
|
name="instructions.txt"
|
||||||
first_name = "Raffu",
|
|
||||||
last_name = "Khondaker",
|
|
||||||
student_id = 1579460,
|
|
||||||
webmail = "2022rkhondak@tjhsst.edu",
|
|
||||||
grade = 10,
|
|
||||||
)
|
)
|
||||||
raffu.save()
|
f1.save()
|
||||||
|
f2 = DefFiles(
|
||||||
#teachers
|
name="instructions.txt"
|
||||||
ng = Teacher(
|
|
||||||
first_name = "Kim",
|
|
||||||
last_name = "Ng",
|
|
||||||
)
|
)
|
||||||
|
f2.save()
|
||||||
ng.save()
|
f3 = DefFiles(
|
||||||
|
name="sample.txt"
|
||||||
chao = Teacher(
|
|
||||||
first_name = "Susie",
|
|
||||||
last_name = "Lebryk-Chao",
|
|
||||||
)
|
)
|
||||||
|
f3.save()
|
||||||
|
f4 = DefFiles(
|
||||||
|
name="rubric.txt"
|
||||||
|
)
|
||||||
|
f4.save()
|
||||||
|
|
||||||
chao.save()
|
a1 = Assignment.objects.get(pk=1)
|
||||||
|
a1.files.add(f1)
|
||||||
|
a1.save()
|
||||||
|
a2 = Assignment.objects.get(pk=2)
|
||||||
|
a2.files.add(f2)
|
||||||
|
a2.save()
|
||||||
|
a3 = Assignment.objects.get(pk=3)
|
||||||
|
a3.files.add(f3)
|
||||||
|
a3.files.add(f4)
|
||||||
|
a3.save()
|
||||||
|
|
||||||
|
####################################
|
||||||
|
|
||||||
|
from api.models import Assignment, Student, Classes, Teacher, DefFiles
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
f1 = DefFiles(
|
||||||
|
name="instructions.txt"
|
||||||
|
)
|
||||||
|
f1.save()
|
||||||
|
f2 = DefFiles(
|
||||||
|
name="instructions.txt"
|
||||||
|
)
|
||||||
|
f2.save()
|
||||||
|
f3 = DefFiles(
|
||||||
|
name="sample.txt"
|
||||||
|
)
|
||||||
|
f3.save()
|
||||||
|
f4 = DefFiles(
|
||||||
|
name="rubric.txt"
|
||||||
|
)
|
||||||
|
f4.save()
|
||||||
|
|
||||||
#Assignments
|
|
||||||
A1 = Assignment(
|
A1 = Assignment(
|
||||||
name='Week1_HW',
|
name='Week1_HW',
|
||||||
due_date=datetime.now(),
|
due_date=datetime.now(),
|
||||||
|
|
||||||
)
|
)
|
||||||
A1.save()
|
A1.save()
|
||||||
|
A1.files.add(f1)
|
||||||
|
A1.save()
|
||||||
|
|
||||||
A2 = Assignment(
|
A2 = Assignment(
|
||||||
name='Week2_HW',
|
name='Week2_HW',
|
||||||
|
@ -40,55 +65,16 @@ A2 = Assignment(
|
||||||
|
|
||||||
)
|
)
|
||||||
A2.save()
|
A2.save()
|
||||||
|
A2.files.add(f2)
|
||||||
|
A2.save()
|
||||||
|
|
||||||
A3 = Assignment(
|
A3 = Assignment(
|
||||||
name='Journal1',
|
name='Journal1',
|
||||||
due_date=datetime.now(),
|
due_date=datetime.now(),
|
||||||
)
|
)
|
||||||
A3.save()
|
A3.save()
|
||||||
|
A3.files.add(f3)
|
||||||
#classes
|
A3.files.add(f4)
|
||||||
C1 = Classes(
|
|
||||||
name='Math5',
|
|
||||||
|
|
||||||
)
|
|
||||||
C1.save()
|
|
||||||
|
|
||||||
C2 = Classes(
|
|
||||||
name='English',
|
|
||||||
)
|
|
||||||
C2.save()
|
|
||||||
|
|
||||||
C2.teachers = chao
|
|
||||||
C2.students.add(raffu)
|
|
||||||
C2.save()
|
|
||||||
|
|
||||||
C1.teachers = ng
|
|
||||||
C1.students.add(raffu)
|
|
||||||
C1.save()
|
|
||||||
|
|
||||||
################################################################################################################
|
|
||||||
from api.models import Assignment, Student, Classes, Teacher
|
|
||||||
from datetime import datetime
|
|
||||||
|
|
||||||
A1 = Assignment(
|
|
||||||
name='Week1_HW',
|
|
||||||
due_date=datetime.now(),
|
|
||||||
|
|
||||||
)
|
|
||||||
A1.save()
|
|
||||||
|
|
||||||
A2 = Assignment(
|
|
||||||
name='Week2_HW',
|
|
||||||
due_date=datetime.now(),
|
|
||||||
|
|
||||||
)
|
|
||||||
A2.save()
|
|
||||||
|
|
||||||
A3 = Assignment(
|
|
||||||
name='Journal1',
|
|
||||||
due_date=datetime.now(),
|
|
||||||
)
|
|
||||||
A3.save()
|
A3.save()
|
||||||
|
|
||||||
#classes
|
#classes
|
||||||
|
@ -113,8 +99,10 @@ raffu = Student(
|
||||||
first_name = "Raffu",
|
first_name = "Raffu",
|
||||||
last_name = "Khondaker",
|
last_name = "Khondaker",
|
||||||
student_id = 1579460,
|
student_id = 1579460,
|
||||||
|
ion_user="2022rkhondak",
|
||||||
webmail = "2022rkhondak@tjhsst.edu",
|
webmail = "2022rkhondak@tjhsst.edu",
|
||||||
grade = 10,
|
grade = 10,
|
||||||
|
repo="https://github.com/therealraffi/2022rkhondak.git",
|
||||||
)
|
)
|
||||||
raffu.save()
|
raffu.save()
|
||||||
raffu.classes.add(math)
|
raffu.classes.add(math)
|
||||||
|
@ -123,16 +111,18 @@ raffu.save()
|
||||||
|
|
||||||
#teachers
|
#teachers
|
||||||
ng = Teacher(
|
ng = Teacher(
|
||||||
first_name = "Kim",
|
first_name = "Errin",
|
||||||
last_name = "Ng",
|
last_name = "Harris",
|
||||||
|
ion_user="eharris1"
|
||||||
)
|
)
|
||||||
ng.save()
|
ng.save()
|
||||||
ng.classes.add(math)
|
ng.classes.add(math)
|
||||||
ng.save()
|
ng.save()
|
||||||
|
|
||||||
chao = Teacher(
|
chao = Teacher(
|
||||||
first_name = "Susie",
|
first_name = "Abagail",
|
||||||
last_name = "Lebryk-Chao",
|
last_name = "Bailey",
|
||||||
|
ion_user="AKBailey"
|
||||||
)
|
)
|
||||||
chao.save()
|
chao.save()
|
||||||
chao.classes.add(english)
|
chao.classes.add(english)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 17:44
|
# Generated by Django 3.0.7 on 2020-06-07 07:45
|
||||||
|
|
||||||
from django.db import migrations, models
|
from django.db import migrations, models
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
class Migration(migrations.Migration):
|
||||||
|
@ -12,50 +11,58 @@ class Migration(migrations.Migration):
|
||||||
]
|
]
|
||||||
|
|
||||||
operations = [
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Assignment',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=100)),
|
||||||
|
('due_date', models.DateTimeField()),
|
||||||
|
],
|
||||||
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Classes',
|
name='Classes',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('url', models.URLField()),
|
('name', models.CharField(max_length=100)),
|
||||||
|
('assignments', models.ManyToManyField(default='', to='api.Assignment')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='DefFiles',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
('name', models.CharField(max_length=100)),
|
('name', models.CharField(max_length=100)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Teacher',
|
name='Teacher',
|
||||||
fields=[
|
fields=[
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('url', models.URLField()),
|
|
||||||
('created', models.DateTimeField(auto_now_add=True)),
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
('first_name', models.CharField(max_length=100)),
|
('first_name', models.CharField(max_length=100)),
|
||||||
('last_name', models.CharField(max_length=100)),
|
('last_name', models.CharField(max_length=100)),
|
||||||
|
('ion_user', models.CharField(max_length=100, primary_key=True, serialize=False)),
|
||||||
|
('git', models.URLField(default='')),
|
||||||
|
('classes', models.ManyToManyField(default='', to='api.Classes')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.CreateModel(
|
migrations.CreateModel(
|
||||||
name='Student',
|
name='Student',
|
||||||
fields=[
|
fields=[
|
||||||
('url', models.URLField()),
|
|
||||||
('created', models.DateTimeField(auto_now_add=True)),
|
('created', models.DateTimeField(auto_now_add=True)),
|
||||||
('first_name', models.CharField(max_length=100)),
|
('first_name', models.CharField(max_length=100)),
|
||||||
('last_name', models.CharField(max_length=100)),
|
('last_name', models.CharField(max_length=100)),
|
||||||
('student_id', models.IntegerField(primary_key=True, serialize=False)),
|
('student_id', models.IntegerField()),
|
||||||
|
('ion_user', models.CharField(max_length=100, primary_key=True, serialize=False)),
|
||||||
|
('webmail', models.EmailField(blank=True, max_length=254)),
|
||||||
('grade', models.IntegerField()),
|
('grade', models.IntegerField()),
|
||||||
('classes', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Classes')),
|
('git', models.URLField()),
|
||||||
|
('repo', models.URLField(default='')),
|
||||||
|
('classes', models.ManyToManyField(default='', to='api.Classes')),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
migrations.AddField(
|
migrations.AddField(
|
||||||
model_name='classes',
|
model_name='assignment',
|
||||||
name='teachers',
|
name='files',
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Teacher'),
|
field=models.ManyToManyField(default='instructions.txt', to='api.DefFiles'),
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='Assignment',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('url', models.URLField()),
|
|
||||||
('name', models.CharField(max_length=100)),
|
|
||||||
('due_date', models.DateTimeField()),
|
|
||||||
('classes', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Classes')),
|
|
||||||
('students', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='api.Student')),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:10
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0001_initial'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Student'),
|
|
||||||
),
|
|
||||||
]
|
|
18
Website/api/migrations/0002_auto_20200607_0751.py
Normal file
18
Website/api/migrations/0002_auto_20200607_0751.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.0.7 on 2020-06-07 07:51
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('api', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='assignment',
|
||||||
|
name='files',
|
||||||
|
field=models.ManyToManyField(to='api.DefFiles'),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1,26 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:17
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0002_auto_20200606_1810'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(blank=True, default='', on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
field=models.ForeignKey(blank=True, default='', on_delete=django.db.models.deletion.CASCADE, to='api.Student'),
|
|
||||||
preserve_default=False,
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:22
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0003_auto_20200606_1817'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='student',
|
|
||||||
name='webmail',
|
|
||||||
field=models.EmailField(blank=True, max_length=254),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:22
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0004_student_webmail'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='student',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,24 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:24
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0005_auto_20200606_1822'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Student'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,21 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:25
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0006_auto_20200606_1824'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:39
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0007_auto_20200606_1825'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Teacher'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,28 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 18:59
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0008_auto_20200606_1839'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='student',
|
|
||||||
name='assignments',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Assignment'),
|
|
||||||
),
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='student',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,40 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 19:10
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0009_auto_20200606_1859'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='url',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='url',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='student',
|
|
||||||
name='url',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='url',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='students',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Student'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 19:16
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0010_auto_20200606_1910'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='assignments',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Assignment'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,17 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 19:47
|
|
||||||
|
|
||||||
from django.db import migrations
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0011_classes_assignments'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='student',
|
|
||||||
name='assignments',
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,27 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 20:04
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0012_remove_student_assignments'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='assignments',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='students',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Classes'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,32 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 20:05
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0013_auto_20200606_2004'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='student',
|
|
||||||
name='classes',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='classes',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='students',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Student'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Teacher'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,32 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 20:23
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0014_auto_20200606_2005'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='classes',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
field=models.ManyToManyField(default='', through='api.Classes', to='api.Student'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='assignments',
|
|
||||||
field=models.ForeignKey(default='', on_delete=django.db.models.deletion.CASCADE, to='api.Assignment'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,19 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 20:24
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0015_auto_20200606_2023'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='api.Teacher'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,35 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 21:01
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0016_classes_teachers'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='assignment',
|
|
||||||
name='students',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='assignments',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='assignments',
|
|
||||||
field=models.ManyToManyField(default='', to='api.Assignment'),
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='students',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='classes',
|
|
||||||
name='students',
|
|
||||||
field=models.ManyToManyField(null=True, to='api.Student'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,18 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 21:07
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0017_auto_20200606_2101'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.AlterField(
|
|
||||||
model_name='classes',
|
|
||||||
name='students',
|
|
||||||
field=models.ManyToManyField(default='', to='api.Student'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,31 +0,0 @@
|
||||||
# Generated by Django 3.0.7 on 2020-06-06 21:26
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
('api', '0018_auto_20200606_2107'),
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='students',
|
|
||||||
),
|
|
||||||
migrations.RemoveField(
|
|
||||||
model_name='classes',
|
|
||||||
name='teachers',
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='student',
|
|
||||||
name='classes',
|
|
||||||
field=models.ManyToManyField(default='', to='api.Classes'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='teacher',
|
|
||||||
name='classes',
|
|
||||||
field=models.ManyToManyField(default='', to='api.Classes'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -1,8 +1,12 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
|
class DefFiles(models.Model):
|
||||||
|
name=models.CharField(max_length=100)
|
||||||
|
|
||||||
class Assignment(models.Model):
|
class Assignment(models.Model):
|
||||||
name=models.CharField(max_length=100)
|
name=models.CharField(max_length=100)
|
||||||
due_date=models.DateTimeField()
|
due_date=models.DateTimeField()
|
||||||
|
files = models.ManyToManyField(DefFiles, default="")
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '%s' % (self.name)
|
return '%s' % (self.name)
|
||||||
|
|
||||||
|
@ -17,15 +21,21 @@ class Teacher(models.Model):
|
||||||
first_name = models.CharField(max_length=100)
|
first_name = models.CharField(max_length=100)
|
||||||
last_name = models.CharField(max_length=100)
|
last_name = models.CharField(max_length=100)
|
||||||
classes = models.ManyToManyField(Classes, default="")
|
classes = models.ManyToManyField(Classes, default="")
|
||||||
|
ion_user=models.CharField(primary_key=True, max_length=100)
|
||||||
|
git = models.URLField(default="")
|
||||||
|
|
||||||
class Student(models.Model):
|
class Student(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
first_name = models.CharField(max_length=100)
|
first_name = models.CharField(max_length=100)
|
||||||
last_name = models.CharField(max_length=100)
|
last_name = models.CharField(max_length=100)
|
||||||
student_id = models.IntegerField(primary_key=True)
|
student_id = models.IntegerField()
|
||||||
|
ion_user=models.CharField(primary_key=True, max_length=100)
|
||||||
webmail = models.EmailField(blank=True)
|
webmail = models.EmailField(blank=True)
|
||||||
grade = models.IntegerField()
|
grade = models.IntegerField()
|
||||||
|
git = models.URLField()
|
||||||
classes = models.ManyToManyField(Classes, default="")
|
classes = models.ManyToManyField(Classes, default="")
|
||||||
|
repo = models.URLField(default="")
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
return super(Student, self).save(*args, **kwargs)
|
return super(Student, self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,19 @@
|
||||||
from django.contrib.auth.models import User, Group
|
from django.contrib.auth.models import User, Group
|
||||||
from .models import Student, Teacher, Classes, Assignment
|
from .models import Student, Teacher, Classes, Assignment, DefFiles
|
||||||
from rest_framework import serializers, permissions
|
from rest_framework import serializers, permissions
|
||||||
|
|
||||||
|
class DefFilesSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
|
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||||
|
class Meta:
|
||||||
|
model = DefFiles
|
||||||
|
fields = ['name']
|
||||||
|
|
||||||
class AssignmentSerializer(serializers.HyperlinkedModelSerializer):
|
class AssignmentSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||||
|
files = DefFilesSerializer(many=True, read_only=True,allow_null=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Assignment
|
model = Assignment
|
||||||
fields = ['name', 'due_date', 'url']
|
fields = ['name', 'due_date', 'url', 'files']
|
||||||
|
|
||||||
class ClassesSerializer(serializers.HyperlinkedModelSerializer):
|
class ClassesSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
assignments = AssignmentSerializer(many=True, read_only=True,allow_null=True)
|
assignments = AssignmentSerializer(many=True, read_only=True,allow_null=True)
|
||||||
|
@ -18,12 +25,12 @@ class StudentSerializer(serializers.HyperlinkedModelSerializer):
|
||||||
classes = ClassesSerializer(many=True, read_only=True,allow_null=True)
|
classes = ClassesSerializer(many=True, read_only=True,allow_null=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Student
|
model = Student
|
||||||
fields = ['url', 'first_name', 'last_name', 'grade','webmail','student_id','classes']
|
fields = ['url', 'first_name', 'last_name', 'grade','webmail','student_id','classes', 'git','repo','ion_user']
|
||||||
|
|
||||||
class TeacherSerializer(serializers.ModelSerializer):
|
class TeacherSerializer(serializers.ModelSerializer):
|
||||||
classes = ClassesSerializer(many=True, read_only=True,allow_null=True)
|
classes = ClassesSerializer(many=True, read_only=True,allow_null=True)
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Teacher
|
model = Teacher
|
||||||
fields = ['url', 'first_name', 'last_name', 'classes']
|
fields = ['url', 'first_name', 'last_name', 'classes','git','ion_user']
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
from .models import Student, Teacher, Classes, Assignment
|
from .models import Student, Teacher, Classes, Assignment, DefFiles
|
||||||
from .serializers import StudentSerializer, TeacherSerializer, ClassesSerializer, AssignmentSerializer
|
from .serializers import StudentSerializer, TeacherSerializer, ClassesSerializer, AssignmentSerializer, DefFilesSerializer
|
||||||
from rest_framework import generics, viewsets, permissions
|
from rest_framework import generics, viewsets, permissions
|
||||||
|
|
||||||
class StudentViewSet(viewsets.ModelViewSet):
|
class StudentViewSet(viewsets.ModelViewSet):
|
||||||
|
@ -33,7 +33,14 @@ class AssignmentViewSet(viewsets.ModelViewSet):
|
||||||
"""
|
"""
|
||||||
API endpoint that allows users to be viewed or edited.
|
API endpoint that allows users to be viewed or edited.
|
||||||
"""
|
"""
|
||||||
permissions_classes = [permissions.IsAdminUser]
|
|
||||||
queryset = Assignment.objects.all()
|
queryset = Assignment.objects.all()
|
||||||
serializer_class = AssignmentSerializer
|
serializer_class = AssignmentSerializer
|
||||||
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||||
|
|
||||||
|
class DefFilesViewSet(viewsets.ModelViewSet):
|
||||||
|
"""
|
||||||
|
API endpoint that allows users to be viewed or edited.
|
||||||
|
"""
|
||||||
|
queryset = DefFiles.objects.all()
|
||||||
|
serializer_class = DefFilesSerializer
|
||||||
|
permissions_classes = [permissions.IsAuthenticatedOrReadOnly]
|
||||||
|
|
|
@ -9,6 +9,8 @@ router.register(r'students', views.StudentViewSet)
|
||||||
router.register(r'teachers', views.TeacherViewSet)
|
router.register(r'teachers', views.TeacherViewSet)
|
||||||
router.register(r'assignments', views.AssignmentViewSet)
|
router.register(r'assignments', views.AssignmentViewSet)
|
||||||
router.register(r'classes', views.ClassesViewSet)
|
router.register(r'classes', views.ClassesViewSet)
|
||||||
|
router.register(r'files', views.DefFilesViewSet)
|
||||||
|
|
||||||
|
|
||||||
# Wire up our API using automatic URL routing.
|
# Wire up our API using automatic URL routing.
|
||||||
# Additionally, we include login URLs for the browsable API.
|
# Additionally, we include login URLs for the browsable API.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user