Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Commit #1

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Django #
*.log
*.pot
*.pyc
__pycache__
db.sqlite3
media

# Backup files #
*.bak

# If you are using PyCharm #
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/gradle.xml
.idea/**/libraries
*.iws /out/

# Python #
*.py[cod]
*$py.class
Empty file added SULearn/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions SULearn/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for SULearn project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'SULearn.settings')

application = get_asgi_application()
153 changes: 153 additions & 0 deletions SULearn/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@


from pathlib import Path
import os
import django_heroku

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

DEBUG = True

ALLOWED_HOSTS = ['localhost','sulearnreq.herokuapp.com']


# Application definition

INSTALLED_APPS = [
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'user',
'crispy_forms',
'course.apps.CourseConfig',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',

]

SITE_ID = 1

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'SULearn.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR,'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.template.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'C.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}


# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Kolkata'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.1/howto/static-files/

SOCIALACCOUNT_PROVIDERS = {
'google': {
'SCOPE': [
'profile',
'email',
],
'AUTH_PARAMS': {
'access_type': 'online',
}
}
}
SECRET_KEY=os.environ.get('SECRET_KEY')
AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend','allauth.account.auth_backends.AuthenticationBackend']
STATIC_ROOT=os.path.join(BASE_DIR,'staticfiles')
STATIC_URL = '/static/'
MEDIA_ROOT=os.path.join(BASE_DIR,'media')
MEDIA_URL='/media/'
'''STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]'''
LOGIN_REDIRECT_URL='home'
ACCOUNT_SIGNUP_REDIRECT_URL = "/viewerform/"
LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = '/'
#SOCIALACCOUNT_ADAPTER='questions.views.MySocialAccount'

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_USE_TLS = True
EMAIL_PORT = 587
EMAIL_HOST_USER = os.environ.get('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_HOST_PASSWORD')
EMAIL_USE_SSL = False
django_heroku.settings(locals())
57 changes: 57 additions & 0 deletions SULearn/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.contrib.auth.views import LogoutView
from django.conf.urls import url
from django.urls import path, include
from user.views import (
Home,
ViewerProfile,
CreatorProfile,
)
from course.views import (
CourseCreate,
CourseDetail,
AddModule,
enroll,
complete,
CourseRate,
CourseDetailNU,
ProfileViewerDetail,
ProfileCreatorDetail,
creatorprofile_edit,
viewerprofile_edit,
search,
creator_following,
CreatorProfilenu,
SubjectList,
ModuleDetail,
)


urlpatterns = [
path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')),
path('logout', LogoutView.as_view(),name='logout'),
path('', Home.as_view(), name='home'),
path('viewerform/',ViewerProfile.as_view(),name='viewerform'),
path('creatorform/',CreatorProfile.as_view(),name='creatorform'),
path('createcourse/',CourseCreate.as_view(),name='create-course'),
path('coursedetail/<pk>/',CourseDetail.as_view(),name='course-detail'),
path('coursedetail/<pk>/addmodule/', AddModule.as_view(),name='add-module'),
path('coursedetail/<pk>/enroll/', enroll,name='enroll'),
path('module/<pk>/complete',complete,name='complete'),
path('course/<pk>/rate',CourseRate.as_view(),name='course-rate'),
path('coursedetailnu/<pk>/',CourseDetailNU.as_view(),name='coursenu'),
path('<str:username>/detail',ProfileViewerDetail.as_view(),name='profileviewer'),
path('<str:username>/creator/detail/',ProfileCreatorDetail.as_view(),name='profilecreator'),
path('creatoredit/',creatorprofile_edit,name='creatorprofile_edit'),
path('vieweredit/',viewerprofile_edit,name='viewerprofile_edit'),
path('results/',search,name='search'),
path('follow/<pk>/',creator_following,name='creator_following'),
path('creatorprofile/<pk>/',CreatorProfilenu.as_view(),name='creatorprofilenu'),
path('subject/<pk>/',SubjectList.as_view(),name='subjectlist'),
path('moduledetail/<pk>/',ModuleDetail.as_view(),name='moduledetail')

]+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

16 changes: 16 additions & 0 deletions SULearn/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for SULearn project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'SULearn.settings')

application = get_wsgi_application()
Empty file added course/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions course/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from django.contrib import admin
from .models import Subject, Course, Module,Completed,CourseRating
# Register your models here.

# register subject in the admin
@admin.register(Subject)
# contents information of the course to show admin
class SubjectAdmin(admin.ModelAdmin):
pass

@admin.register(Module)
# contents information of the course to show admin
class ModuleAdmin(admin.ModelAdmin):
pass

# register admin for course
@admin.register(Course)
class CourseAdmin(admin.ModelAdmin):
pass

@admin.register(Completed)
class CompletedAdmin(admin.ModelAdmin):
pass
@admin.register(CourseRating)
class CourseRatingAdmin(admin.ModelAdmin):
pass
7 changes: 7 additions & 0 deletions course/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.apps import AppConfig


class CourseConfig(AppConfig):
name = 'course'
def ready(self):
import course.signals
24 changes: 24 additions & 0 deletions course/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django import forms
from django.contrib.auth.models import User
from user.models import CreatorProfile,ViewerProfile


class UserUpdateForm(forms.ModelForm):
first_name = forms.CharField(label='First Name')
last_name = forms.CharField(label='last Name', required=False)
class Meta:
model = User
fields = ['username', 'first_name', 'last_name']


class CreatorProfileUpdateForm(forms.ModelForm):
edu = forms.CharField(label='Education qualification', required=False)

class Meta:
model = CreatorProfile
fields = ['city','state','dob','edu', 'image']

class ViewerProfileUpdateForm(forms.ModelForm):
class Meta:
model = ViewerProfile
fields = ['city','state','dob', 'image']
58 changes: 58 additions & 0 deletions course/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 3.1.7 on 2021-03-25 20:01

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone


class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Course',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200, unique=True)),
('overview', models.TextField()),
('created', models.DateTimeField(auto_now_add=True)),
('rating', models.DecimalField(decimal_places=2, default=0, max_digits=2)),
('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='courses_created', to=settings.AUTH_USER_MODEL)),
('students', models.ManyToManyField(blank=True, related_name='courses_joined', to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ['-created'],
},
),
migrations.CreateModel(
name='Subject',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
],
options={
'ordering': ['title'],
},
),
migrations.CreateModel(
name='Module',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=200)),
('description', models.TextField(blank=True)),
('date', models.DateTimeField(default=django.utils.timezone.now)),
('course', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='modules', to='course.course')),
],
),
migrations.AddField(
model_name='course',
name='subject',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='courses', to='course.subject'),
),
]
Loading