mirror of
https://github.com/Rushilwiz/chirper.git
synced 2025-04-09 15:00:20 -04:00
Initial commit
This commit is contained in:
commit
c8be363bf9
129
.gitignore
vendored
Normal file
129
.gitignore
vendored
Normal file
|
@ -0,0 +1,129 @@
|
||||||
|
# Byte-compiled / optimized / DLL files
|
||||||
|
__pycache__/
|
||||||
|
*.py[cod]
|
||||||
|
*$py.class
|
||||||
|
|
||||||
|
# C extensions
|
||||||
|
*.so
|
||||||
|
|
||||||
|
# Distribution / packaging
|
||||||
|
.Python
|
||||||
|
build/
|
||||||
|
develop-eggs/
|
||||||
|
dist/
|
||||||
|
downloads/
|
||||||
|
eggs/
|
||||||
|
.eggs/
|
||||||
|
lib/
|
||||||
|
lib64/
|
||||||
|
parts/
|
||||||
|
sdist/
|
||||||
|
var/
|
||||||
|
wheels/
|
||||||
|
pip-wheel-metadata/
|
||||||
|
share/python-wheels/
|
||||||
|
*.egg-info/
|
||||||
|
.installed.cfg
|
||||||
|
*.egg
|
||||||
|
MANIFEST
|
||||||
|
|
||||||
|
# PyInstaller
|
||||||
|
# Usually these files are written by a python script from a template
|
||||||
|
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||||
|
*.manifest
|
||||||
|
*.spec
|
||||||
|
|
||||||
|
# Installer logs
|
||||||
|
pip-log.txt
|
||||||
|
pip-delete-this-directory.txt
|
||||||
|
|
||||||
|
# Unit test / coverage reports
|
||||||
|
htmlcov/
|
||||||
|
.tox/
|
||||||
|
.nox/
|
||||||
|
.coverage
|
||||||
|
.coverage.*
|
||||||
|
.cache
|
||||||
|
nosetests.xml
|
||||||
|
coverage.xml
|
||||||
|
*.cover
|
||||||
|
*.py,cover
|
||||||
|
.hypothesis/
|
||||||
|
.pytest_cache/
|
||||||
|
|
||||||
|
# Translations
|
||||||
|
*.mo
|
||||||
|
*.pot
|
||||||
|
|
||||||
|
# Django stuff:
|
||||||
|
*.log
|
||||||
|
local_settings.py
|
||||||
|
db.sqlite3
|
||||||
|
db.sqlite3-journal
|
||||||
|
|
||||||
|
# Flask stuff:
|
||||||
|
instance/
|
||||||
|
.webassets-cache
|
||||||
|
|
||||||
|
# Scrapy stuff:
|
||||||
|
.scrapy
|
||||||
|
|
||||||
|
# Sphinx documentation
|
||||||
|
docs/_build/
|
||||||
|
|
||||||
|
# PyBuilder
|
||||||
|
target/
|
||||||
|
|
||||||
|
# Jupyter Notebook
|
||||||
|
.ipynb_checkpoints
|
||||||
|
|
||||||
|
# IPython
|
||||||
|
profile_default/
|
||||||
|
ipython_config.py
|
||||||
|
|
||||||
|
# pyenv
|
||||||
|
.python-version
|
||||||
|
|
||||||
|
# pipenv
|
||||||
|
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||||
|
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||||
|
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||||
|
# install all needed dependencies.
|
||||||
|
#Pipfile.lock
|
||||||
|
|
||||||
|
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||||
|
__pypackages__/
|
||||||
|
|
||||||
|
# Celery stuff
|
||||||
|
celerybeat-schedule
|
||||||
|
celerybeat.pid
|
||||||
|
|
||||||
|
# SageMath parsed files
|
||||||
|
*.sage.py
|
||||||
|
|
||||||
|
# Environments
|
||||||
|
.env
|
||||||
|
.venv
|
||||||
|
env/
|
||||||
|
venv/
|
||||||
|
ENV/
|
||||||
|
env.bak/
|
||||||
|
venv.bak/
|
||||||
|
|
||||||
|
# Spyder project settings
|
||||||
|
.spyderproject
|
||||||
|
.spyproject
|
||||||
|
|
||||||
|
# Rope project settings
|
||||||
|
.ropeproject
|
||||||
|
|
||||||
|
# mkdocs documentation
|
||||||
|
/site
|
||||||
|
|
||||||
|
# mypy
|
||||||
|
.mypy_cache/
|
||||||
|
.dmypy.json
|
||||||
|
dmypy.json
|
||||||
|
|
||||||
|
# Pyre type checker
|
||||||
|
.pyre/
|
2
README.md
Normal file
2
README.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# chirper
|
||||||
|
definitely not another social media platform that allows you to write small blurbs of text 150 chars or less
|
0
chirper/blog/__init__.py
Normal file
0
chirper/blog/__init__.py
Normal file
4
chirper/blog/admin.py
Normal file
4
chirper/blog/admin.py
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from .models import Post
|
||||||
|
|
||||||
|
admin.site.register(Post)
|
5
chirper/blog/apps.py
Normal file
5
chirper/blog/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class BlogConfig(AppConfig):
|
||||||
|
name = 'blog'
|
28
chirper/blog/migrations/0001_initial.py
Normal file
28
chirper/blog/migrations/0001_initial.py
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# Generated by Django 3.0.5 on 2020-04-30 04:08
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Post',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=100)),
|
||||||
|
('content', models.TextField()),
|
||||||
|
('date_posted', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('likes', models.IntegerField()),
|
||||||
|
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
18
chirper/blog/migrations/0002_auto_20200430_0415.py
Normal file
18
chirper/blog/migrations/0002_auto_20200430_0415.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 3.0.5 on 2020-04-30 04:15
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('blog', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='post',
|
||||||
|
name='likes',
|
||||||
|
field=models.IntegerField(default=0),
|
||||||
|
),
|
||||||
|
]
|
0
chirper/blog/migrations/__init__.py
Normal file
0
chirper/blog/migrations/__init__.py
Normal file
15
chirper/blog/models.py
Normal file
15
chirper/blog/models.py
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
from django.db import models
|
||||||
|
from django.utils import timezone
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
|
||||||
|
class Post(models.Model):
|
||||||
|
title = models.CharField(max_length=100)
|
||||||
|
content = models.TextField()
|
||||||
|
date_posted = models.DateTimeField(auto_now_add=True)
|
||||||
|
author = models.ForeignKey(User, on_delete=models.CASCADE)
|
||||||
|
likes = models.IntegerField(default=0)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.title
|
BIN
chirper/blog/static/blog/futura.ttf
Normal file
BIN
chirper/blog/static/blog/futura.ttf
Normal file
Binary file not shown.
92
chirper/blog/static/blog/styles.css
Normal file
92
chirper/blog/static/blog/styles.css
Normal file
|
@ -0,0 +1,92 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: Futura;
|
||||||
|
src: url(futura.ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #fafafa;
|
||||||
|
color: #333333;
|
||||||
|
margin-top: 5rem;
|
||||||
|
font-family: Futura;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #444444;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bg-steel {
|
||||||
|
background: #5f788a;
|
||||||
|
background: linear-gradient(to right, #ec008c, #fc6767);
|
||||||
|
border-bottom: 3px #111 solid;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-header .navbar-nav .nav-link {
|
||||||
|
color: #cbd5db;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-header .navbar-nav .nav-link:hover {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.site-header .navbar-nav .nav-link.active {
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-section {
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 10px 20px;
|
||||||
|
border: 1px solid #dddddd;
|
||||||
|
border-radius: 3px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-title {
|
||||||
|
color: #444444;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.article-title:hover {
|
||||||
|
color: #428bca;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-content {
|
||||||
|
white-space: pre-line;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-img {
|
||||||
|
height: 65px;
|
||||||
|
width: 65px;
|
||||||
|
margin-right: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-metadata {
|
||||||
|
padding-bottom: 1px;
|
||||||
|
margin-bottom: 4px;
|
||||||
|
border-bottom: 1px solid #e3e3e3
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-metadata a:hover {
|
||||||
|
color: #333;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.article-svg {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-img {
|
||||||
|
height: 125px;
|
||||||
|
width: 125px;
|
||||||
|
margin-right: 20px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.account-heading {
|
||||||
|
font-size: 2.5rem;
|
||||||
|
}
|
4
chirper/blog/templates/blog/about.html
Normal file
4
chirper/blog/templates/blog/about.html
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{% extends "blog/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>About Page</h1>
|
||||||
|
{% endblock content %}
|
58
chirper/blog/templates/blog/base.html
Normal file
58
chirper/blog/templates/blog/base.html
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
{% load static %}
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en" dir="ltr">
|
||||||
|
<head>
|
||||||
|
<!-- Required meta tags -->
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
|
||||||
|
<!-- Bootstrap CSS -->
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<link href="https://emoji-css.afeld.me/emoji.css" rel="stylesheet">
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="{% static 'blog/styles.css' %}">
|
||||||
|
|
||||||
|
|
||||||
|
<title>Chirper🐦</title>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header class="site-header">
|
||||||
|
<nav class="navbar navbar-expand-md navbar-dark bg-steel fixed-top">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand mr-4" href="{% url 'blog-home' %}">Chirper
|
||||||
|
<i class="em em-bird" aria-role="presentation" aria-label="BIRD"></i>
|
||||||
|
</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggle" aria-controls="navbarToggle" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarToggle">
|
||||||
|
<div class="navbar-nav mr-auto">
|
||||||
|
<a class="nav-item nav-link" href="{% url 'blog-home' %}">Home</a>
|
||||||
|
<a class="nav-item nav-link" href="{% url 'blog-about' %}">About</a>
|
||||||
|
</div>
|
||||||
|
<!-- Navbar Right Side -->
|
||||||
|
<div class="navbar-nav">
|
||||||
|
<a class="nav-item nav-link" href="{% url 'login' %}">Login</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<main role="main" class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<!-- Bootstrap JS -->
|
||||||
|
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
15
chirper/blog/templates/blog/home.html
Normal file
15
chirper/blog/templates/blog/home.html
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{% extends "blog/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
{% for post in posts %}
|
||||||
|
<article class="media content-section">
|
||||||
|
<div class="media-body">
|
||||||
|
<div class="article-metadata">
|
||||||
|
<a class="mr-2" href="#">{{ post.author }}</a>
|
||||||
|
<small class="text-muted">{{ post.date_posted }}</small>
|
||||||
|
</div>
|
||||||
|
<h2><a class="article-title" href="#">{{ post.title }}</a></h2>
|
||||||
|
<p class="article-content">{{ post.content }}</p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock content %}
|
3
chirper/blog/tests.py
Normal file
3
chirper/blog/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
chirper/blog/urls.py
Normal file
7
chirper/blog/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.home, name='blog-home'),
|
||||||
|
path('about/', views.about, name='blog-about'),
|
||||||
|
]
|
11
chirper/blog/views.py
Normal file
11
chirper/blog/views.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from django.shortcuts import render
|
||||||
|
from .models import Post
|
||||||
|
|
||||||
|
def home (request):
|
||||||
|
context = {
|
||||||
|
'posts': Post.objects.all()
|
||||||
|
}
|
||||||
|
return render(request, 'blog/home.html', context)
|
||||||
|
|
||||||
|
def about (request):
|
||||||
|
return render(request, 'blog/about.html', {'title': 'About'})
|
0
chirper/chirper/__init__.py
Normal file
0
chirper/chirper/__init__.py
Normal file
16
chirper/chirper/asgi.py
Normal file
16
chirper/chirper/asgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
ASGI config for chirper 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.0/howto/deployment/asgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chirper.settings')
|
||||||
|
|
||||||
|
application = get_asgi_application()
|
133
chirper/chirper/settings.py
Normal file
133
chirper/chirper/settings.py
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
"""
|
||||||
|
Django settings for chirper project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 3.0.6.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/3.0/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/3.0/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
# Override HTTPS requirement for OauthLib
|
||||||
|
os.environ['OAUTHLIB_INSECURE_TRANSPORT'] = '1'
|
||||||
|
|
||||||
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = 'j**92w*kzbnf-hvz&waa*@2t5^%og8j%7g#waak%c^$4bo4dop'
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
CORS_ORIGIN_ALLOW_ALL = True
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
AUTHENTICATION_BACKENDS = (
|
||||||
|
'oauth2_provider.backends.OAuth2Backend',
|
||||||
|
'django.contrib.auth.backends.ModelBackend'
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'blog.apps.BlogConfig',
|
||||||
|
'users.apps.UsersConfig',
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'oauth2_provider',
|
||||||
|
'corsheaders',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
'oauth2_provider.middleware.OAuth2TokenMiddleware',
|
||||||
|
'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',
|
||||||
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'chirper.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
'DIRS': [],
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'chirper.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.sqlite3',
|
||||||
|
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/3.0/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.0/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/3.0/howto/static-files/
|
||||||
|
|
||||||
|
STATIC_URL = '/static/'
|
25
chirper/chirper/urls.py
Normal file
25
chirper/chirper/urls.py
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
"""chirper URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/3.0/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
|
Including another URLconf
|
||||||
|
1. Import the include() function: from django.urls import include, path
|
||||||
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
|
"""
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path, include
|
||||||
|
from users import views as user_views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', include('blog.urls')),
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('login/', include('users.urls')),
|
||||||
|
path("o/", include('oauth2_provider.urls', namespace='oauth2_provider')),
|
||||||
|
]
|
16
chirper/chirper/wsgi.py
Normal file
16
chirper/chirper/wsgi.py
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
"""
|
||||||
|
WSGI config for chirper 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.0/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chirper.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
1
chirper/file.html
Normal file
1
chirper/file.html
Normal file
File diff suppressed because one or more lines are too long
21
chirper/manage.py
Executable file
21
chirper/manage.py
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chirper.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()
|
0
chirper/users/__init__.py
Normal file
0
chirper/users/__init__.py
Normal file
3
chirper/users/admin.py
Normal file
3
chirper/users/admin.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
5
chirper/users/apps.py
Normal file
5
chirper/users/apps.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class UsersConfig(AppConfig):
|
||||||
|
name = 'users'
|
0
chirper/users/migrations/__init__.py
Normal file
0
chirper/users/migrations/__init__.py
Normal file
3
chirper/users/models.py
Normal file
3
chirper/users/models.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
6
chirper/users/templates/users/callback.html
Normal file
6
chirper/users/templates/users/callback.html
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{% extends "blog/base.html" %}
|
||||||
|
{% block content %}
|
||||||
|
<div class="content-section">
|
||||||
|
<a class="btn btn-primary btn-lg btn-block" href="#" role="button">Sign in with Ion</a>
|
||||||
|
</div>
|
||||||
|
{% endblock content %}
|
1
chirper/users/templates/users/login.html
Normal file
1
chirper/users/templates/users/login.html
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<h1>you shouldn't be here</h1>
|
3
chirper/users/tests.py
Normal file
3
chirper/users/tests.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
7
chirper/users/urls.py
Normal file
7
chirper/users/urls.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('', views.login, name='login'),
|
||||||
|
path('callback/', views.callback),
|
||||||
|
]
|
33
chirper/users/views.py
Normal file
33
chirper/users/views.py
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
from django.shortcuts import render, redirect
|
||||||
|
from requests_oauthlib import OAuth2Session
|
||||||
|
from django.views.decorators.csrf import csrf_exempt
|
||||||
|
import requests
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
|
||||||
|
client_id = r'6p7HJlFCD8cnBNBEdgMsdULS5ph0jserw1xvWfxX'
|
||||||
|
client_secret = r'E1e79KebxzAp0LBEtxcUg32b0qFP9Ap9Dxqkac6Qhci5AwXFhSfrbe7MtmGJUh6DDgxivJpGgFYNQgusfvoSraDAnsq3NnEET5DmxgfBBvvuYc2bwDq6KpeKIDQqFtwz'
|
||||||
|
redirect_uri = 'http://localhost:8000/login/callback/'
|
||||||
|
token_url = 'https://ion.tjhsst.edu/oauth/authorize/'
|
||||||
|
scope=["read","write"]
|
||||||
|
|
||||||
|
def login(request):
|
||||||
|
client = requests.session()
|
||||||
|
|
||||||
|
oauth = OAuth2Session(client_id=client_id, redirect_uri=redirect_uri, scope=scope)
|
||||||
|
authorization_url, state = oauth.authorization_url("https://ion.tjhsst.edu/oauth/authorize/")
|
||||||
|
print(f'a_url: {authorization_url}')
|
||||||
|
|
||||||
|
return redirect(authorization_url)
|
||||||
|
|
||||||
|
# {'grant_type':'authorization_code','code':code,'redirect_uri':redirect_uri,'client_id':client_id,'client_secret':client_secret}
|
||||||
|
|
||||||
|
|
||||||
|
def callback(request):
|
||||||
|
return render(request, 'users/callback.html')
|
||||||
|
code = fr"{request.GET.get('code')}"
|
||||||
|
payload = {'grant_type':'authorization_code','code':code,'redirect_uri':redirect_uri,'client_id':client_id,'client_secret':client_secret}
|
||||||
|
token = requests.post(token_url, data=payload)
|
||||||
|
#print (code)
|
||||||
|
#token = oauth.fetch_token(token_url=token_url, code=code, client_secret=client_secret)
|
||||||
|
print(token)
|
Loading…
Reference in New Issue
Block a user