Began development of custom user action backend, and basic templating.

This commit is contained in:
Raelon Masters
2020-07-18 02:34:43 -04:00
parent 7221701f7f
commit 7ea017d790
9 changed files with 123 additions and 48 deletions

View File

@@ -52,7 +52,7 @@ INSTALLED_APPS = [
"interface.templatetags",
"debug_toolbar",
]
AUTH_USER_MODEL = "interface.CustomUser"
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
@@ -135,6 +135,6 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/
LOGIN_REDIRECT_URL = 'home'
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(BASE_DIR, "interface/static/")

View File

@@ -16,12 +16,13 @@ Including another URLconf
from django.conf import settings
from django.contrib import admin
from django.urls import include, path, re_path
from django.contrib.auth import views as auth_views
from interface import views
urlpatterns = [
path("admin/", admin.site.urls),
path("", views.index, name="index"),
path("home", views.home, name="index"),
path("home", views.home, name="home"),
path("sort/<_order>", views.index, name="index"),
path("flip_sort/<_order>", views.flip_sort, name="index"),
path("download/<pk>", views.download, name="download"),
@@ -35,7 +36,30 @@ urlpatterns = [
path("search/", views.index, name="search"),
path("search/<query>", views.index, name="search"),
path("search/<query>/<_set>", views.index, name="search"),
path("show_collection/<_collection>/<_colset>", views.show_collection, name="show_collection",),
path("show_collection/<_collection>/<_colset>", views.show_collection, name="show_collection"),
path("signup", views.signup, name="signup"),
path("login", views.userlogin, name="login"),
path('logout', views.userlogout, name='logout'),
path(
'admin/password_reset/',
auth_views.PasswordResetView.as_view(),
name='admin_password_reset',
),
path(
'admin/password_reset/done/',
auth_views.PasswordResetDoneView.as_view(),
name='password_reset_done',
),
path(
'reset/<uidb64>/<token>/',
auth_views.PasswordResetConfirmView.as_view(),
name='password_reset_confirm',
),
path(
'reset/done/',
auth_views.PasswordResetCompleteView.as_view(),
name='password_reset_complete',
),
]
if settings.DEBUG:
import debug_toolbar

View File

@@ -1,5 +1,7 @@
from django.contrib.postgres.search import SearchVector
from django.db import models
from django.conf import settings
from django.contrib.auth.models import AbstractUser
# Create your models here.
@@ -40,12 +42,13 @@ class Books(models.Model):
def generic_search(self, query):
try:
results = Books.objects.annotate(
search=SearchVector("title", "file_name", "author","tags"),
search=SearchVector("title", "file_name", "author", "tags"),
).filter(search=query)
except Exception as e:
raise
return results
class Collections(models.Model):
class Meta:
db_table = "collections"
@@ -69,6 +72,7 @@ class Collections(models.Model):
raise
return results
class Navigation(models.Model):
"""
pyShelfs Navigation Database class
@@ -105,38 +109,6 @@ class Navigation(models.Model):
raise
return results
class Users(models.Model):
"""
pyShelfs User Database class
:param uname: User Name
:param fname: First Name
:param lname: Last Name
:param email: User Email Address
:param password: User Password
:param ulvl: User Level
"""
class Meta:
db_table = "users"
def __str__(self):
return self.title
uname = models.CharField(max_length=255)
fname = models.CharField(max_length=255, null=True)
lname = models.CharField(max_length=255, null=True)
email = models.CharField(max_length=255, null=True, editable=True)
password = models.CharField(max_length=255, null=True)
ulvl = models.IntegerField(null=True)
def generic_search(self, query):
try:
results = Users.objects.annotate(
search=SearchVector("uname", "email", "lname"),
).filter(search=query)
except Exception as e:
raise
return results
class Favorites(models.Model):
"""
@@ -152,7 +124,7 @@ class Favorites(models.Model):
return self.title
favorite = models.ManyToManyField(Books)
uname = models.ManyToManyField(Users)
uname = models.ManyToManyField(settings.AUTH_USER_MODEL)
def generic_search(self, query):
try:
@@ -162,3 +134,11 @@ class Favorites(models.Model):
except Exception as e:
raise
return results
class CustomUser(AbstractUser):
facebook = models.CharField(max_length=255, null=True)
twitter = models.CharField(max_length=255, null=True)
ulvl = models.IntegerField(default=1)
sponsorid = models.IntegerField(null=True)
matrixid = models.CharField(max_length=255, null=True)

View File

@@ -1,3 +1,3 @@
/*! Select2 4.0.7 | https://github.com/select2/select2/blob/master/LICENSE.md */
dfqqyn*! Select2 4.0.7 | https://github.com/select2/select2/blob/master/LICENSE.md */
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/el",[],function(){return{errorLoading:function(){return"Τα αποτελέσματα δεν μπόρεσαν να φορτώσουν."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Παρακαλώ διαγράψτε "+t+" χαρακτήρ";return t==1&&(n+="α"),t!=1&&(n+="ες"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Παρακαλώ συμπληρώστε "+t+" ή περισσότερους χαρακτήρες";return n},loadingMore:function(){return"Φόρτωση περισσότερων αποτελεσμάτων…"},maximumSelected:function(e){var t="Μπορείτε να επιλέξετε μόνο "+e.maximum+" επιλογ";return e.maximum==1&&(t+="ή"),e.maximum!=1&&(t+="ές"),t},noResults:function(){return"Δεν βρέθηκαν αποτελέσματα"},searching:function(){return"Αναζήτηση…"},removeAllItems:function(){return"Καταργήστε όλα τα στοιχεία"}}}),{define:e.define,require:e.require}})();
(function(){if(jQuery&&jQuery.fn&&jQuery.fn.select2&&jQuery.fn.select2.amd)var e=jQuery.fn.select2.amd;return e.define("select2/i18n/el",[],function(){return{errorLoading:function(){return"Τα αποτελέσματα δεν μπόρεσαν να φορτώσουν."},inputTooLong:function(e){var t=e.input.length-e.maximum,n="Παρακαλώ διαγράψτε "+t+" χαρακτήρ";return t==1&&(n+="α"),t!=1&&(n+="ες"),n},inputTooShort:function(e){var t=e.minimum-e.input.length,n="Παρακαλώ συμπληρώστε "+t+" ή περισσότερους χαρακτήρες";return n},loadingMore:function(){return"Φόρτωση περισσότερων αποτελεσμάτων…"},maximumSelected:function(e){var t="Μπορείτε να επιλέξετε μόνο "+e.maximum+" επιλογ";return e.maximum==1&&(t+="ή"),e.maximum!=1&&(t+="ές"),t},noResults:function(){return"Δεν βρέθηκαν αποτελέσματα"},searching:function(){return"Αναζήτηση…"},removeAllItems:function(){return"Καταργήστε όλα τα στοιχεία"}}}),{define:e.define,require:e.require}})();

BIN
src/interface/static/img/inspectocat.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -27,10 +27,10 @@
<input type="hidden" id="_order" name="_order" value="{{ Order }}" />
<div id="pop_over_0">
<!-- Login Form -->
<div class="hdr_nav" id="hdr_nav_login">
<input id="username" class="nav_login input_box noborder" type="text" size="8" value="Username">
<input id="password" class="nav_login input_box noborder" type="text" size="8" value="Password">
</div>
<div class="hdr_nav" id="hdr_nav_login">
<input id="username" class="nav_login input_box noborder" type="text" size="8" value="Username">
<input id="password" class="nav_login input_box noborder" type="text" size="8" value="Password">
</div>
<!-- End Login Form -->
</div>
<div id="app">
@@ -44,9 +44,9 @@
<li class="nav_menu_tab"><i class="fas fa-star"></i>&nbsp;Favorites</li>
<li class="nav_menu_tab"><i class="fas fa-bug"></i>&nbsp;Bug report</li>
<li class="nav_menu_tab" id="btn_login"> <i class="fa fa-user-circle" aria-hidden="true"></i>&nbsp;Login</li>
</div>
</div>
<div id="horiz_nav_main">
</div>
</div>
<div id="horiz_nav_main">
<div id="horiz_nav_left">
<i class="fas fa-arrow-circle-left nav_icon prev_page" onclick="window.location.href = '/prev_page/{{ Set }}/{{ Order }}'"></i>
&nbsp;sort <i class="fas fa-sort nav_icon"></i>
@@ -88,7 +88,7 @@
{% elif book.description == None %}
<li class="book_description">
<div class="inline_sys_message">
We were unable to find a description in this books metadata.
We were unable to find a description.
<br />Have some <i class="fas fa-drumstick-bite"></i> instead?
</div>
</li>

23
src/interface/templates/login.html vendored Normal file
View File

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2>Login</h2>
<form method="post">
{% csrf_token %}
{% for field in form %}
<div class="fieldWrapper">
{{ field.errors }}
{{ field.label_tag }} {{ field }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
<button type="submit">Login</button>
</form>
</body>
</html>

View File

@@ -0,0 +1,22 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2>Login</h2>
<form method="post">
{% for field in form %}
<div class="fieldWrapper">
{{ field.errors }}
{{ field.label_tag }} {{ field }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
{% endfor %}
<button type="submit">Login</button>
</form>
</body>
</html>

26
src/interface/templates/signup.html vendored Normal file
View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h2>Sign up</h2>
<form method="post">
{% csrf_token %}
{% for field in form %}
<p>
{{ field.label_tag }}<br>
{{ field }}
{% if field.help_text %}
<small style="color: grey">{{ field.help_text }}</small>
{% endif %}
{% for error in field.errors %}
<p style="color: red">{{ error }}</p>
{% endfor %}
</p>
{% endfor %}
<button type="submit">Sign up</button>
</form>
</body>
</html>