Skip to content

Commit

Permalink
Merge branch 'development' of https://github.com/nfoert/cardie
Browse files Browse the repository at this point in the history
  • Loading branch information
nfoert committed Jul 2, 2024
2 parents bdcf4cd + f7a5fe5 commit a9bfa97
Show file tree
Hide file tree
Showing 198 changed files with 36,813 additions and 27 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.venv
cardie/db.sqlite3
__pycache__
59 changes: 59 additions & 0 deletions .vscode/tasks.json
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": []
}
]
}
34 changes: 7 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,32 @@
</p>

# Welcome to Cardie!
Design a unlimited number of buisness or information cards about yourself, share a link or QR code to them, print it out, and save other people's cards to your virtual wallet for later. Once you've created a card you can get analytics data on how your cards are getting visited, you can edit your cards as things change, and you can keep cards private so only people with a link to your card can see it.
Design a unlimited number of business or information cards about yourself, share a link or QR code to them, print it out, and save other people's cards to your virtual wallet for later. Once you've created a card you can get analytics data on how your cards are getting visited, you can edit your cards as things change, and you can keep cards private so only people with a link to your card can see it.

<p align="center">
<a href="https://skillicons.dev">
<img src="https://skillicons.dev/icons?i=django,python,html,css,js,github,git"/>
<img src="https://skillicons.dev/icons?i=django,python,html,css,js,github,git,alpinejs"/>
</a>
</p>

## Installation

> [!IMPORTANT]
> These directions are for a develeopment server only right now. This project is not currently developed enough for production use.
> These directions are for a development server only right now. This project is not currently developed enough for production use.

First, clone this repository using the following command
```
git clone https://github.com/nfoert/cardie
```

Then, navigate to that directory and create a new python virtual enviroment
Then, navigate to that directory and create a new python virtual environment
```
cd cardie
python3 -m venv .venv
```

Activate the virtual enviroment using the command for your system (Linux is used here) and install the required dependencies
Activate the virtual environment using the command for your system (Linux is used here) and install the required dependencies
```
source ./.venv/bin/activate
pip install -r requirements.txt
Expand All @@ -48,27 +48,7 @@ python manage.py runserver
```

## To Do
There's lots of basic things that need done before this project can truly begin. Here's a rough todo list of the main things that still need completed.

- [ ] Logo design
- [ ] Basic django project up and running
- [ ] Design UI elements
- [ ] Basic home page
- [ ] Authentication system
- [ ] User model
- [ ] Sign in and create account views
- [ ] Functional authentication pages and browser persistence
- [ ] Card design
- [ ] Basic home page design
- [ ] Card models
- [ ] Card UI element
- [ ] Basic card customization
- [ ] Card sharing
- [ ] Link generation
- [ ] QR code generation
- [ ] Card printing
- [ ] Save to wallet
- [ ] Ability to log out
There's lots of things that need implemented or changed in this project. Please see [TODO.md](TODO.md).

## Contributing
I'd love to see contributions to this project! However, there's not enough development on it yet to warrant contributions. Once progress is made and beta releases start going out, I'll organize more to prepare for contributions.
I'd love to see contributions to this project! Please check out the [issues](https://github.com/nfoert/issues) page to see what things currently need fixed or added.
16 changes: 16 additions & 0 deletions TODO.md
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.
3 changes: 3 additions & 0 deletions cardie/authentication/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 cardie/authentication/apps.py
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'
24 changes: 24 additions & 0 deletions cardie/authentication/migrations/0001_initial.py
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 cardie/authentication/migrations/0002_alter_user_date_created.py
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.
10 changes: 10 additions & 0 deletions cardie/authentication/models.py
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)
3 changes: 3 additions & 0 deletions cardie/authentication/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.
8 changes: 8 additions & 0 deletions cardie/authentication/urls.py
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"),
]
88 changes: 88 additions & 0 deletions cardie/authentication/views.py
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 added cardie/cardie/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions cardie/cardie/asgi.py
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()
Loading

0 comments on commit a9bfa97

Please sign in to comment.