-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' of https://github.com/nfoert/cardie
- Loading branch information
Showing
198 changed files
with
36,813 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.venv | ||
cardie/db.sqlite3 | ||
__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"label": "Start server", | ||
"type": "shell", | ||
"command": "source .venv/bin/activate && python ./cardie/manage.py runserver", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"runOptions": { | ||
"runOn": "folderOpen" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Start server (external)", | ||
"type": "shell", | ||
"command": "source .venv/bin/activate && python ./cardie/manage.py runserver 192.168.1.103:1111", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Migrate models", | ||
"type": "shell", | ||
"command": "source .venv/bin/activate && python ./cardie/manage.py makemigrations && python ./cardie/manage.py migrate", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
{ | ||
"label": "Collect static files", | ||
"type": "shell", | ||
"command": "source .venv/bin/activate && python ./cardie/manage.py collectstatic --noinput", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"problemMatcher": [] | ||
}, | ||
// Thanks to https://github.com/pypa/pip/issues/4318#issuecomment-284272355 | ||
{ | ||
"label": "Pip freeze", | ||
"type": "shell", | ||
"command": "source .venv/bin/activate && pip freeze | sed s/=.*// > requirements.txt", | ||
"presentation": { | ||
"reveal": "always", | ||
"panel": "new" | ||
}, | ||
"problemMatcher": [] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# To-Do | ||
This list shows some of the next things that need implemented for Cardie. I want to figure out a better solution for a todo list in future but this works for now. | ||
|
||
- [ ] Make UIs mobile friendly [issue](https://github.com/nfoert/cardie/issues/4) | ||
- [ ] **Customization** | ||
- [ ] Background Color | ||
- [ ] Secondary Color | ||
- [ ] Collapse Links | ||
- [ ] If no text, make link button only | ||
- [ ] **Authentication UI improvements** [issue](https://github.com/nfoert/cardie/issues/2) | ||
- [ ] Animate box changes | ||
- [ ] Make Cardie logo clickable to go home | ||
- [ ] Privacy policy | ||
- [ ] Animate showing warning box in authentication | ||
- [ ] Enter shortcut for signing in and creating an account | ||
- [ ] Some elements use underscores for Ids and some use dashes [issue](https://github.com/nfoert/cardie/issues/18) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AuthenticationConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'authentication' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Generated by Django 5.0.3 on 2024-04-25 20:13 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('username', models.CharField(max_length=64)), | ||
('password', models.CharField(max_length=512)), | ||
('email', models.CharField(max_length=256)), | ||
('date_created', models.DateField(blank=True)), | ||
], | ||
), | ||
] |
18 changes: 18 additions & 0 deletions
18
cardie/authentication/migrations/0002_alter_user_date_created.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 5.0.3 on 2024-04-25 20:16 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('authentication', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='user', | ||
name='date_created', | ||
field=models.DateTimeField(blank=True), | ||
), | ||
] |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.db import models | ||
|
||
class User(models.Model): | ||
username = models.CharField(max_length=64) | ||
password = models.CharField(max_length=512) | ||
email = models.CharField(max_length=256) | ||
date_created = models.DateTimeField(blank=True) | ||
|
||
def __str__(self): | ||
return(self.username) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import path | ||
|
||
from . import views | ||
|
||
urlpatterns = [ | ||
path("signin", views.sign_in, name="sign_in"), | ||
path("createaccount", views.create_account, name="createaccount"), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
from django.shortcuts import render, HttpResponse | ||
from django.contrib.auth.hashers import make_password, check_password | ||
|
||
from authentication.models import User | ||
from main.models import Server | ||
from main import views | ||
|
||
from django.utils import timezone | ||
|
||
def sign_in(request): | ||
server = Server.objects.all()[0] # TODO: What if there is multiple server objects? | ||
|
||
if server.allow_sign_in: | ||
if "Username" in request.headers and "Password" in request.headers: | ||
username = request.headers["Username"] | ||
password = request.headers["Password"] | ||
|
||
signed_in = True | ||
|
||
else: | ||
try: | ||
username = request.session["username"] | ||
password = request.session["password"] | ||
|
||
signed_in = True | ||
|
||
except KeyError: | ||
print("Missing headers and no session!") | ||
return HttpResponse("error_missing_headers_and_session") | ||
|
||
|
||
if signed_in: | ||
users = User.objects.filter(username=username) | ||
|
||
if len(users) == 1: | ||
password_check = check_password(password, users[0].password) | ||
|
||
if password_check: | ||
request.session["username"] = username | ||
request.session["password"] = password | ||
|
||
if request.headers["Internal"] == "true": | ||
return HttpResponse("success") | ||
|
||
else: | ||
return views.home(request) | ||
|
||
else: | ||
return HttpResponse("error_password_wrong") | ||
|
||
elif len(users) == 0: | ||
return HttpResponse("error_no_accounts") | ||
|
||
elif len(users) > 1: | ||
return HttpResponse("error_multiple_accounts_exist") | ||
else: | ||
return HttpResponse("error_sign_in_disabled") | ||
|
||
|
||
def create_account(request): | ||
server = Server.objects.all()[0] # TODO: What if there is multiple server objects? | ||
|
||
if server.allow_create_accounts: | ||
if "Username" in request.headers and "Password" in request.headers and "Email" in request.headers: | ||
username = request.headers["Username"] | ||
password = request.headers["Password"] | ||
email = request.headers["Email"] | ||
|
||
users = User.objects.filter(username=username) | ||
|
||
if len(users) > 0: | ||
return HttpResponse("error_account_already_exists") | ||
|
||
else: | ||
hashed_password = make_password(password) | ||
|
||
user = User(username=username, password=hashed_password, email=email, date_created=timezone.now()) | ||
user.save() | ||
|
||
request.session["username"] = username | ||
request.session["password"] = password | ||
|
||
return sign_in(request) | ||
|
||
else: | ||
return HttpResponse("error_missing_headers") | ||
else: | ||
return HttpResponse("error_create_account_disabled") |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
""" | ||
ASGI config for cardie 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/5.0/howto/deployment/asgi/ | ||
""" | ||
|
||
import os | ||
|
||
from django.core.asgi import get_asgi_application | ||
|
||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'cardie.settings') | ||
|
||
application = get_asgi_application() |
Oops, something went wrong.