mirror of
https://github.com/th3r00t/pyShelf.git
synced 2026-04-28 01:59:35 -04:00
Began development of custom user action backend, and basic templating.
This commit is contained in:
@@ -52,7 +52,7 @@ INSTALLED_APPS = [
|
|||||||
"interface.templatetags",
|
"interface.templatetags",
|
||||||
"debug_toolbar",
|
"debug_toolbar",
|
||||||
]
|
]
|
||||||
|
AUTH_USER_MODEL = "interface.CustomUser"
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
"django.middleware.security.SecurityMiddleware",
|
"django.middleware.security.SecurityMiddleware",
|
||||||
"django.contrib.sessions.middleware.SessionMiddleware",
|
"django.contrib.sessions.middleware.SessionMiddleware",
|
||||||
@@ -135,6 +135,6 @@ USE_TZ = True
|
|||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||||
|
LOGIN_REDIRECT_URL = 'home'
|
||||||
STATIC_URL = "/static/"
|
STATIC_URL = "/static/"
|
||||||
STATIC_ROOT = os.path.join(BASE_DIR, "interface/static/")
|
STATIC_ROOT = os.path.join(BASE_DIR, "interface/static/")
|
||||||
|
|||||||
@@ -16,12 +16,13 @@ Including another URLconf
|
|||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import include, path, re_path
|
from django.urls import include, path, re_path
|
||||||
|
from django.contrib.auth import views as auth_views
|
||||||
from interface import views
|
from interface import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("admin/", admin.site.urls),
|
path("admin/", admin.site.urls),
|
||||||
path("", views.index, name="index"),
|
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("sort/<_order>", views.index, name="index"),
|
||||||
path("flip_sort/<_order>", views.flip_sort, name="index"),
|
path("flip_sort/<_order>", views.flip_sort, name="index"),
|
||||||
path("download/<pk>", views.download, name="download"),
|
path("download/<pk>", views.download, name="download"),
|
||||||
@@ -35,7 +36,30 @@ urlpatterns = [
|
|||||||
path("search/", views.index, name="search"),
|
path("search/", views.index, name="search"),
|
||||||
path("search/<query>", views.index, name="search"),
|
path("search/<query>", views.index, name="search"),
|
||||||
path("search/<query>/<_set>", 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:
|
if settings.DEBUG:
|
||||||
import debug_toolbar
|
import debug_toolbar
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
from django.contrib.postgres.search import SearchVector
|
from django.contrib.postgres.search import SearchVector
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
|
from django.contrib.auth.models import AbstractUser
|
||||||
|
|
||||||
# Create your models here.
|
# Create your models here.
|
||||||
|
|
||||||
@@ -46,6 +48,7 @@ class Books(models.Model):
|
|||||||
raise
|
raise
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
class Collections(models.Model):
|
class Collections(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = "collections"
|
db_table = "collections"
|
||||||
@@ -69,6 +72,7 @@ class Collections(models.Model):
|
|||||||
raise
|
raise
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
class Navigation(models.Model):
|
class Navigation(models.Model):
|
||||||
"""
|
"""
|
||||||
pyShelfs Navigation Database class
|
pyShelfs Navigation Database class
|
||||||
@@ -105,38 +109,6 @@ class Navigation(models.Model):
|
|||||||
raise
|
raise
|
||||||
return results
|
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):
|
class Favorites(models.Model):
|
||||||
"""
|
"""
|
||||||
@@ -152,7 +124,7 @@ class Favorites(models.Model):
|
|||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
favorite = models.ManyToManyField(Books)
|
favorite = models.ManyToManyField(Books)
|
||||||
uname = models.ManyToManyField(Users)
|
uname = models.ManyToManyField(settings.AUTH_USER_MODEL)
|
||||||
|
|
||||||
def generic_search(self, query):
|
def generic_search(self, query):
|
||||||
try:
|
try:
|
||||||
@@ -162,3 +134,11 @@ class Favorites(models.Model):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise
|
raise
|
||||||
return results
|
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)
|
||||||
|
|||||||
@@ -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
BIN
src/interface/static/img/inspectocat.jpg
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
2
src/interface/templates/index.html
vendored
2
src/interface/templates/index.html
vendored
@@ -88,7 +88,7 @@
|
|||||||
{% elif book.description == None %}
|
{% elif book.description == None %}
|
||||||
<li class="book_description">
|
<li class="book_description">
|
||||||
<div class="inline_sys_message">
|
<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?
|
<br />Have some <i class="fas fa-drumstick-bite"></i> instead?
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
23
src/interface/templates/login.html
vendored
Normal file
23
src/interface/templates/login.html
vendored
Normal 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>
|
||||||
22
src/interface/templates/registration/login.html
vendored
Normal file
22
src/interface/templates/registration/login.html
vendored
Normal 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
26
src/interface/templates/signup.html
vendored
Normal 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>
|
||||||
Reference in New Issue
Block a user