Skip to content
This repository was archived by the owner on Nov 3, 2019. It is now read-only.

Creating django app and models #1

Merged
merged 4 commits into from
Jul 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# cc_backend

### Introduction
CC_backend is back-end part of the "CodeClassRoom" project whose front-end will be based on REACT.This backend is built by [Gagan Singh](https://github.com/GAGANsinghmsitece) and
[Bhupesh](https://github.com/Bhupesh-V).


### Prerequisties
- Python 3.6.8+
- virtualenv
Expand Down
Empty file added codeclassroom/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions codeclassroom/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions codeclassroom/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class CodeclassroomConfig(AppConfig):
name = 'codeclassroom'
Empty file.
56 changes: 56 additions & 0 deletions codeclassroom/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
from django.db import models
from django.contrib.auth.models import User

'''From signup api endpoint we are expecting json response be like
{'user':'Gagansingh','password':#########,'choice':'Student/Professor'}
depending on choice we will create their student or prof model'''


class Student(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
name=models.CharField(max_length=100,blank=True)
ProfilePic=models.ImageField(upload_to='StudentProfilePic',blank=True)
College_Name=models.CharField(max_length=200,blank=True)
Course=models.CharField(max_length=50,blank=True)

class Professor(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE)
name=models.CharField(max_length=100,blank=True)
ProfilePic=models.ImageField(upload_to='ProfessorProfilePic',blank=True)
College_Name=models.CharField(max_length=200,blank=True)

'''I'm assuming a professor can create multiple classrooms and each classroom can have
multiple classroom. if a classroom is deleted, all of the assignments of that class will
delete automatically'''

class ClassRoom(models.Model):
professor=models.ForeignKey(Professor,on_delete=models.CASCADE)
title=models.CharField(max_length=200,blank=False)
Picture=models.ImageField(upload_to='ClassMedia',blank=False)
student=models.ManyToManyField(Student,blank=True)
#because a student can join multiple classroom and each classroom can have multiple
#students.For more info, refer to official docs


class Assignments(models.Model):
classroom=models.ForeignKey(ClassRoom,on_delete=models.CASCADE)
title=models.CharField(max_length=200,blank=False)

class Questions(models.Model):
assignment=models.ForeignKey(codeclassroom,on_delete=models.CASCADE)
content=models.CharField(max_length=2000,blank=False)

'''NOW i will be making a reponse model ,i.e., response of a student for a assignment

'''
class Respopnse(models.Model):
question=models.ForeignKey(Questions,on_delete=models.CASCADE)
student=models.ForeignKey(Student,on_delete=models.CASCADE)
answer=models.CharField(max_length=40000,blank=False)
remark=models.CharField(max_length=500,blank=True)#this field may be filled by prof
#as remark

### this project is built by "codeclassroom" organisation and all rights are thereby
#reserved.Please ask before copying this code or project
# happy coding!!!

3 changes: 3 additions & 0 deletions codeclassroom/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
3 changes: 3 additions & 0 deletions codeclassroom/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.shortcuts import render

# Create your views here.