mirror of
https://github.com/Rushilwiz/SkoolOS.git
synced 2025-04-16 02:10:19 -04:00
Merge branch 'development' of https://github.com/Rushilwiz/SkoolOS into development
This commit is contained in:
commit
ecaa0faf39
|
@ -1,5 +1,6 @@
|
|||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
import secrets
|
||||
|
||||
|
||||
|
||||
|
@ -12,7 +13,6 @@ class Student(models.Model):
|
|||
classes=models.CharField(max_length=100, default="", blank=True)
|
||||
added_to=models.CharField(max_length=100, default="", blank=True)
|
||||
completed=models.TextField(default="", blank=True)
|
||||
ion_user=models.CharField(primary_key=True, max_length=100)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
super(Student, self).save(*args, **kwargs)
|
||||
|
@ -37,6 +37,7 @@ class Class(models.Model):
|
|||
owner = models.ForeignKey('auth.User', related_name='classes', on_delete=models.CASCADE)
|
||||
teacher = models.CharField(max_length=100)
|
||||
name = models.CharField(primary_key=True, max_length=100)
|
||||
id = models.CharField(max_length=8, blank=True, null=True)
|
||||
description = models.CharField(default="Class Description", max_length=500)
|
||||
repo=models.URLField(default="", blank=True)
|
||||
path=models.CharField(max_length=100, default="")
|
||||
|
@ -48,6 +49,12 @@ class Class(models.Model):
|
|||
# assignments = models.ManyToManyField(Assignment, default="")
|
||||
# default_file = models.ManyToManyField(DefFiles)
|
||||
def save(self, *args, **kwargs):
|
||||
id = self.id
|
||||
if not id:
|
||||
id = secrets.token_urlsafe()[:8].lower()
|
||||
while Class.objects.filter(id=id).exclude(pk=self.pk).exists():
|
||||
id = sercrets.token_urlsafe()[:8].lower()
|
||||
self.id = id
|
||||
return super(Class, self).save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="content-section">
|
||||
{% for class in classes %}
|
||||
<div class="card-columns">
|
||||
<a class="card" href="#" style="text-decoration: none;">
|
||||
<a class="card" href="/class/{{ class.pk }}" style="text-decoration: none;">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ class.name }}</h5>
|
||||
<p class="card-text">{{ class.description }}</p>
|
||||
|
|
|
@ -5,5 +5,6 @@ from . import views
|
|||
# Additionally, we include login URLs for the browsable API.
|
||||
urlpatterns = [
|
||||
path('', views.home, name='home'),
|
||||
path('profile/', views.profile, name='profile')
|
||||
path('profile/', views.profile, name='profile'),
|
||||
path("class/<int:id>", views.classDetail, name="class"),
|
||||
]
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import render, redirect
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.views.generic import ListView
|
||||
|
||||
from api.models import Student, Teacher
|
||||
from api.models import Student, Teacher, Class, Assignment
|
||||
|
||||
# Create your views here.
|
||||
|
||||
|
@ -24,3 +25,7 @@ def home (request):
|
|||
@login_required()
|
||||
def profile (request):
|
||||
pass
|
||||
|
||||
def classDetail (request, id):
|
||||
classObj = Class.objects.get(id=id)
|
||||
return redirect('/')
|
||||
|
|
Loading…
Reference in New Issue
Block a user