Skip to content

Commit

Permalink
Backend setup
Browse files Browse the repository at this point in the history
  • Loading branch information
kunal2812 committed Oct 6, 2023
1 parent ae41433 commit 26ccfcc
Show file tree
Hide file tree
Showing 155 changed files with 3,238 additions and 3,275 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
env
main/__pycache__
youdemy/__pycache__
db.sqlite3
5 changes: 5 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Contributors

Add your name in the given format.

- [Kunal Katiyar](https://github.com/kunal2812/)
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Youdemy

Youdemy is an online learning platform that offers a wide range of courses on Computer programming, allowing individuals to acquire new skills and knowledge at their own pace.

## Getting Started

## How to run locally?
* [Install Python](https://www.wikihow.com/Install-Python)
* Clone this repository
```
git clone https://github.com/ContriHUB/Youdemy.git
```
* Create Virtual Environment
```
cd Youdemy
```
* Create Virtual Environment
```
python -m venv env
```
* Activate the environment
* On Windows, run: `env\Scripts\activate`
* On Linux/Mac, run: `source env/bin/activate`
* Install the dependencies
```
pip install -r requirements.txt
```
* To apply the migrations run,
```
python manage.py makemigrations
```
```
python manage.py migrate
```
* Now to run the server, and visit `http://127.0.0.1:8000/`.
```
python manage.py runserver
```
* To access admin panel, you need to be superuser. Follow [this](https://www.geeksforgeeks.org/how-to-create-superuser-in-django/) link for instructions.
For help getting started with Django, view [online documentation](https://docs.djangoproject.com/en/4.1/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
You can also ChatGPT for taking references.
##### Steps to contribute -
1. Fork this repo and clone it to your system.
2. Get the issue assigned to you on the [ContriHUB](https://sac.mnnit.ac.in/contrihub/) website.
3. Make the required changes. Please keep your changes relevant only to the issue specified.
4. Add your name to [CONTRIBUTORS.md](CONTRIBUTORS.md).
5. Create a PR with your changes and a detailed description of the changes you have made.
6. Submit the PR link on the ContriHUB website.
[_References for contributing_](https://github.com/ContriHUB/ContriHUB-23#reference-links)
## Contributors
A list of contributors can be found in [CONTRIBUTORS.md](CONTRIBUTORS.md).
Binary file removed images/person_1.jpg
Binary file not shown.
Binary file removed images/person_2.jpg
Binary file not shown.
Empty file added main/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions main/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.
6 changes: 6 additions & 0 deletions main/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'
Empty file added main/migrations/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions main/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
3 changes: 3 additions & 0 deletions main/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.
16 changes: 16 additions & 0 deletions main/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('', views.home, name="home"),
path('courses', views.courses, name="courses"),
path('project', views.projects, name="projects"),
path('contact', views.contact, name="contact"),
path('blog', views.blog, name="blog"),
path('blog_single', views.blog_single, name="blog_single"),
path('course1', views.course1, name="course1"),
path('course2', views.course2, name="course2"),
path('course3', views.course3, name="course3"),
path('account', views.account, name="account"),
path('signout', views.signout, name="signout"),
]
85 changes: 85 additions & 0 deletions main/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from django.shortcuts import redirect, render
from django.http import HttpResponse
from django.contrib.auth.models import User
from django.contrib import messages
from django.contrib.auth import authenticate, login, logout
# Create your views here.
def home(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/index.html", {"fname": user_first_name})

def courses(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/courses.html", {"fname": user_first_name})

def course1(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/course1.html", {"fname": user_first_name})

def course2(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/course2.html", {"fname": user_first_name})

def course3(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/course3.html", {"fname": user_first_name})

def projects(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/project.html", {"fname": user_first_name})

def blog(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/blog.html", {"fname": user_first_name})

def blog_single(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/blog-single.html", {"fname": user_first_name})


def contact(request):
user_first_name = request.session.get('user_first_name', 'Guest')
return render(request, "main/contact.html", {"fname": user_first_name})


def account(request):
if request.method == "POST":
action = request.POST.get('submit_action')
if action == 'signup':
uname = request.POST['uname']
fname = request.POST['fname']
lname = request.POST['lname']
email = request.POST['email']
pass1 = request.POST['pass1']
pass2 = request.POST['pass2']

if pass1 == pass2:
# Create a new user
user = User.objects.create_user(username=uname, email=email, password=pass1)
user.first_name = fname
user.last_name = lname
user.save()
messages.success(request, "User registered successfully")
return redirect('signin') # Redirect to the login page
else:
messages.error(request, "Passwords do not match")

elif action == 'signin':
uname = request.POST['uname']
pass1 = request.POST['pass1']
user = authenticate(username=uname, password=pass1)
if user is not None:
login(request,user)
# print(user.first_name)
messages.success(request, "Signed in successfully")
request.session['user_first_name'] = user.first_name
return redirect('home')
else:
messages.error(request, "Invalid Credentials")
return redirect('home')
return render(request, 'main/index.html')

def signout(request):
logout(request)
messages.success(request, "Logged out successfully")
return redirect('home')
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'youdemy.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Binary file added requirements.txt
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions css/self.css → static/css/self.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.optioncode{
color:black;
}
.optioncode{
color:black;
}
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Binary file added static/images/person_1.jpg
Binary file added static/images/person_2.jpg
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 26ccfcc

Please sign in to comment.