Skip to content

Commit

Permalink
Merge branch 'main' into Dark-mode
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBanzon committed Nov 7, 2023
2 parents ab8be82 + 438abee commit 46fff50
Show file tree
Hide file tree
Showing 33 changed files with 671 additions and 498 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: [3.10.7]
python-version: [3.12]

steps:
- uses: actions/checkout@v3
Expand Down
11 changes: 7 additions & 4 deletions ACMAS/.env
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# DO NOT UPLOAD ANY CHANGES TO GITHUB!
DATABASE=postgres
DEBUG=1
DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] 52.60.213.127 www.acmas.systems acmas.systems
DJANGO_ALLOWED_HOSTS='localhost 127.0.0.1 [::1] 52.55.52.58 www.acmas.systems acmas.systems'
DJANGO_EMAIL=[email protected]
DJANGO_PASS=password
DJANGO_USER=acmas_admin
GOOGLE_ADSENSE_ID=INSERT_ID_HERE
GOOGLE_ADSENSE_URL=https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=
GOOGLE_ANALYTICS_ID=INSERT_ID_HERE
GOOGLE_ANALYTICS_URL=https://www.googletagmanager.com/gtag/js?id=
POSTGRES_DB=acmas_db
POSTGRES_PASSWORD=PASSWORD
POSTGRES_USER=acmas_admin
SECRET_KEY=SECRET_KEY
SQL_DATABASE=acmas_db
SQL_ENGINE=django.db.backends.postgresql
SQL_HOST=db
SQL_PASSWORD=PASSWORD
SQL_PORT=5432
SQL_USER=acmas_admin
4 changes: 0 additions & 4 deletions ACMAS/.env.db

This file was deleted.

13 changes: 8 additions & 5 deletions ACMAS/app/ACMAS/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

# 'DJANGO_ALLOWED_HOSTS' should be a single string of hosts with a space between each.
# For example: 'DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1]'
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", default="").split(" ")
ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS", default="").strip("'").split(" ")

# Application definition

Expand All @@ -37,7 +37,7 @@
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_components.safer_staticfiles",
"ACMAS_Web",
"django_components",
]
Expand Down Expand Up @@ -86,9 +86,9 @@
DATABASES = {
"default": {
"ENGINE": os.environ.get("SQL_ENGINE", "django.db.backends.postgresql"),
"NAME": os.environ.get("SQL_DATABASE", BASE_DIR / "acmas_db"),
"USER": os.environ.get("SQL_USER", "user"),
"PASSWORD": os.environ.get("SQL_PASSWORD", "password"),
"NAME": os.environ.get("POSTGRES_DB", BASE_DIR / "acmas_db"),
"USER": os.environ.get("POSTGRES_USER", "user"),
"PASSWORD": os.environ.get("POSTGRES_PASSWORD", "password"),
"HOST": os.environ.get("SQL_HOST", "localhost"),
"PORT": os.environ.get("SQL_PORT", "5432"),
}
Expand Down Expand Up @@ -142,3 +142,6 @@
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

LOGIN_REDIRECT_URL = "/"
LOGOUT_REDIRECT_URL = "/"
14 changes: 12 additions & 2 deletions ACMAS/app/ACMAS_Web/admin.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# from django.contrib import admin
from django.contrib import admin

# Register your models here.
from .models import Course, Question, University, UploadedFile, User

admin.site.register(Question)
admin.site.register(University)
admin.site.register(Course)
admin.site.register(UploadedFile)
admin.site.register(User)

admin.site.site_header = "ACMAS Admin"
admin.site.site_title = "ACMAS Admin Portal"
admin.site.index_title = "Welcome to the ACMAS Administration Portal"
6 changes: 3 additions & 3 deletions ACMAS/app/ACMAS_Web/components/button/button.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<span class="button-component pt-2">
<span class="button-component">
{% if component_type == "primary" %}
<button type="submit" class="px-4 py-2 rounded-xl text-white text-semibold text-lg bg-blue-600 hover:bg-blue-700 transition ease-in duration-200" value="{{ value }}" name="{{ name }}">{{ text }}</button>
<button type="submit" class="px-5 py-3 rounded-xl text-white font-semibold text-lg bg-blue-600 hover:bg-blue-700 transition ease-in duration-200" value="{{ value }}" name="{{ name }}">{{ text }}</button>
{% elif component_type == "secondary" %}
<button type="submit" class="px-4 py-2 rounded-xl text-gray-700 text-semibold border border-gray-300 text-lg bg-white hover:bg-gray-100 transition ease-in duration-200" value="{{ value }}" name="{{ name }}">{{ text }}</button>
<button type="submit" class="px-5 py-3 rounded-xl text-gray-700 font-semibold border border-gray-300 text-lg bg-white hover:bg-gray-100 transition ease-in duration-200" value="{{ value }}" name="{{ name }}">{{ text }}</button>
{% endif %}
</span>
48 changes: 44 additions & 4 deletions ACMAS/app/ACMAS_Web/components/field/field.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,47 @@
<div class="field-component p-0.5">
{% load component_tags %}

<div class="field-component relative flex bg-gray-100 p-4 h-14 space-x-4 rounded-lg w-full items-center">
{% if component_type == "input" %}
<input type="file" class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 dark:text-gray-400 focus:outline-none dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400" name="{{ name }}">
{% else %}
<input type="text" class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" name="{{ name }}" placeholder="{{ placeholder }}">
<input type="file" class="block w-full text-sm text-gray-900 border border-gray-300 rounded-lg cursor-pointer bg-gray-50 focus:outline-none" name="{{ name }}">
{% else %}
{% if icon_name != "" %}
{% component "icon" icon=icon_name icon_type="mini" icon_class="w-6 h-6 flex-shrink-0 text-gray-400" %}
{% endif %}
<input type="{{ component_type }}" class="peer bg-gray-100 outline-none border-0 w-full ring-0 focus:ring-0" name="{{ name }}" placeholder="{{ placeholder }}" />
{% endif %}
{% if name == "password1" and placeholder == "Create password..." %}
<div class="-left-48 absolute invisible peer-focus:visible">
<div class="w-40 h-40 flex flex-col bg-white text-gray-600 text-xs rounded-xl text-left p-4 border border-light-gray z-50 justify-items-center">
<p class="text-center">Password can't be:</p>
<ul class="list-disc pl-2 gap-y-2">
<li>too similar to other personal information</li>
<li>less than 8 characters </li>
<li>be a commonly used password</li>
<li>entirely numeric</li>
</ul>
</div>
<div class="relative z-30">
<div class="flex left-full -ml-3 bottom-20 absolute z-0">
<div class="h-4 w-4 origin-bottom-left rotate-45 transform border border-light-gray bg-white border-b-white border-l-white"></div>
</div>
</div>
</div>
{% endif %}
{% if name == "username" and placeholder == "Create username..." %}
<div class="absolute -left-48 invisible peer-focus:visible">
<div class="w-40 h-40 flex-col flex bg-white text-gray-600 text-xs rounded-xl text-left p-4 border border-light-gray z-50 justify-items-center">
<p class="text-center">Required</p>
<ul class="pl-2 list-disc gap-y-2">
<li>150 characters or fewer</li>
<li>Letters, digits and @/./+/-/_ only</li>
<li>Must not be fully numeric</li>
</ul>
</div>
<div class="z-30 relative">
<div class="flex -ml-3 left-full bottom-20 absolute z-0">
<div class="w-4 h-4 origin-bottom-left rotate-45 transform border border-light-gray bg-white border-b-white border-l-white"></div>
</div>
</div>
</div>
{% endif %}
</div>
3 changes: 2 additions & 1 deletion ACMAS/app/ACMAS_Web/components/field/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
class Field(component.Component):
template_name = "field/field.html"

def get_context_data(self, placeholder, name, component_type):
def get_context_data(self, placeholder, name, component_type, icon_name):
return {
"placeholder": placeholder,
"name": name,
"component_type": component_type,
"icon_name": icon_name,
}
11 changes: 11 additions & 0 deletions ACMAS/app/ACMAS_Web/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django import forms
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User


class RegisterForm(UserCreationForm):
email = forms.EmailField()

class Meta:
model = User
fields = ["username", "email", "password1", "password2"]
31 changes: 31 additions & 0 deletions ACMAS/app/ACMAS_Web/management/commands/ensure_admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os

from django.contrib.auth import get_user_model
from django.core.management.base import BaseCommand


class Command(BaseCommand):
help = "Creates an admin user non-interactively if it doesn't exist"

def add_arguments(self, parser):
parser.add_argument("--username", help="Admin's username")
parser.add_argument("--email", help="Admin's email")
parser.add_argument("--password", help="Admin's password")
parser.add_argument(
"--no-input", help="Read options from the environment", action="store_true"
)

def handle(self, *args, **options):
User = get_user_model()

if options["no_input"]:
options["username"] = os.environ["$DJANGO_USER"]
options["email"] = os.environ["DJANGO_SUPERUSER_EMAIL"]
options["password"] = os.environ["DJANGO_SUPERUSER_PASSWORD"]

if not User.objects.filter(username=options["username"]).exists():
User.objects.create_superuser(
username=options["username"],
email=options["email"],
password=options["password"],
)
16 changes: 16 additions & 0 deletions ACMAS/app/ACMAS_Web/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ class University(models.Model):
def __str__(self):
return self.name

class Meta:
verbose_name_plural = "Universities"


class Course(models.Model):
name = models.TextField()
Expand All @@ -40,3 +43,16 @@ class UploadedFile(models.Model):

def __str__(self):
return self.filename

class Meta:
verbose_name = "Uploaded File"
verbose_name_plural = "Uploaded Files"


class User(models.Model):
username = models.CharField(max_length=50)
password = models.CharField(max_length=50)
email = models.CharField(max_length=50)

def __str__(self):
return self.username
1 change: 1 addition & 0 deletions ACMAS/app/ACMAS_Web/static/img/ACMAS_Black-White_Logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ACMAS/app/ACMAS_Web/static/img/RCOS.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ACMAS/app/ACMAS_Web/static/img/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 46fff50

Please sign in to comment.