aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBobby <[email protected]>2024-12-15 19:11:48 -0500
committerBobby <[email protected]>2024-12-15 19:11:48 -0500
commit8bb529d5eefec11360e7aacb287120d6427793bd (patch)
tree356d0690288513eee99abedafd3cf0929a3f27a3
parent12c92bf4d74f3717b1eafe1737e671a2b8bda02e (diff)
downloadthatcomputerscientist-8bb529d5eefec11360e7aacb287120d6427793bd.tar.xz
thatcomputerscientist-8bb529d5eefec11360e7aacb287120d6427793bd.zip
user stats
-rw-r--r--apps/blog/views.py8
-rw-r--r--ignis/views.py2
-rw-r--r--internal/weblog_utilities.py9
-rw-r--r--middleware/userprofilemiddleware.py2
-rw-r--r--services/users/__init__.py (renamed from users/__init__.py)0
-rw-r--r--services/users/accountFunctions.py (renamed from users/accountFunctions.py)23
-rw-r--r--services/users/admin.py (renamed from users/admin.py)0
-rw-r--r--services/users/apps.py6
-rw-r--r--services/users/forms.py (renamed from users/forms.py)2
-rw-r--r--services/users/mail_send.py (renamed from users/mail_send.py)0
-rw-r--r--services/users/migrations/0001_initial.py (renamed from users/migrations/0001_initial.py)0
-rw-r--r--services/users/migrations/0002_userprofile_email_verified.py (renamed from users/migrations/0002_userprofile_email_verified.py)0
-rw-r--r--services/users/migrations/0003_captchastore.py (renamed from users/migrations/0003_captchastore.py)0
-rw-r--r--services/users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py (renamed from users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py)0
-rw-r--r--services/users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py (renamed from users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py)0
-rw-r--r--services/users/migrations/0006_delete_captchastore.py (renamed from users/migrations/0006_delete_captchastore.py)0
-rw-r--r--services/users/migrations/0007_captchastore.py (renamed from users/migrations/0007_captchastore.py)0
-rw-r--r--services/users/migrations/0008_remove_userprofile_gravatar_email_and_more.py (renamed from users/migrations/0008_remove_userprofile_gravatar_email_and_more.py)0
-rw-r--r--services/users/migrations/0009_delete_captchastore.py (renamed from users/migrations/0009_delete_captchastore.py)0
-rw-r--r--services/users/migrations/0010_userprofile_blinkie_url.py (renamed from users/migrations/0010_userprofile_blinkie_url.py)0
-rw-r--r--services/users/migrations/0011_tokenstore.py (renamed from users/migrations/0011_tokenstore.py)0
-rw-r--r--services/users/migrations/0012_alter_tokenstore_expires.py (renamed from users/migrations/0012_alter_tokenstore_expires.py)0
-rw-r--r--services/users/migrations/__init__.py (renamed from users/migrations/__init__.py)0
-rw-r--r--services/users/models.py (renamed from users/models.py)0
-rw-r--r--services/users/templates/email_change_verification_email.html (renamed from users/templates/email_change_verification_email.html)0
-rw-r--r--services/users/templates/reset_password_email.html (renamed from users/templates/reset_password_email.html)0
-rw-r--r--services/users/templates/verification_email.html (renamed from users/templates/verification_email.html)0
-rw-r--r--services/users/tests.py (renamed from users/tests.py)0
-rw-r--r--services/users/tokens.py (renamed from users/tokens.py)0
-rw-r--r--services/users/urls.py (renamed from users/urls.py)0
-rw-r--r--services/users/views.py (renamed from users/views.py)0
-rw-r--r--static/css/shared/core.css65
-rw-r--r--static/css/shared/login-area.css4
-rw-r--r--static/images/core/icons/coin.pngbin0 -> 5172 bytes
-rw-r--r--templates/en/core/home.html2
-rw-r--r--templates/ja/core/home.html1
-rw-r--r--templates/shared/right_sidebar.html42
-rw-r--r--thatcomputerscientist/settings.py4
-rw-r--r--thatcomputerscientist/urls.py1
-rw-r--r--users/apps.py6
40 files changed, 149 insertions, 28 deletions
diff --git a/apps/blog/views.py b/apps/blog/views.py
index fe9bc41f..07022263 100644
--- a/apps/blog/views.py
+++ b/apps/blog/views.py
@@ -23,15 +23,15 @@ from haystack.query import SearchQuerySet
from user_agents import parse
from apps.administration.models import Announcement
-from users.accountFunctions import verify_token
-from users.forms import (
+from services.users.accountFunctions import verify_token
+from services.users.forms import (
RegisterForm,
ResetPasswordForm,
UpdateUserDetailsForm,
ForgotPasswordForm,
)
-from users.models import UserProfile
-from users.tokens import CaptchaTokenGenerator
+from services.users.models import UserProfile
+from services.users.tokens import CaptchaTokenGenerator
from .context_processors import (
add_excerpt,
diff --git a/ignis/views.py b/ignis/views.py
index aa9a87d5..f681f64d 100644
--- a/ignis/views.py
+++ b/ignis/views.py
@@ -9,7 +9,7 @@ from django.views.decorators.csrf import csrf_exempt
from PIL import Image
from apps.blog.models import Post
-from users.tokens import CaptchaTokenGenerator
+from services.users.tokens import CaptchaTokenGenerator
from .models import PostImage, RepositoryTitle
diff --git a/internal/weblog_utilities.py b/internal/weblog_utilities.py
index a6eede4b..db4fc5d5 100644
--- a/internal/weblog_utilities.py
+++ b/internal/weblog_utilities.py
@@ -1,6 +1,8 @@
from apps.blog.models import Post, Comment
from bs4 import BeautifulSoup
+AUTHOR_USERNAME = "bobby"
+
def add_excerpt(post, lang="en"):
if lang == "ja":
@@ -14,7 +16,6 @@ def add_excerpt(post, lang="en"):
if len(excerpt) >= 1000:
break
- print(excerpt)
return excerpt
@@ -23,8 +24,10 @@ def add_num_comments(post):
return num_comments
-def recent_weblogs(lang="en"):
- recent_posts = Post.objects.filter(is_public=True).order_by("-date")[:5]
+def recent_weblogs(lang="en", amount=3):
+ recent_posts = Post.objects.filter(
+ is_public=True, author__username=AUTHOR_USERNAME
+ ).order_by("-date")[:amount]
for post in recent_posts:
post.excerpt = add_excerpt(post, lang)
post.num_comments = add_num_comments(post)
diff --git a/middleware/userprofilemiddleware.py b/middleware/userprofilemiddleware.py
index 25e43c14..dc6c8bac 100644
--- a/middleware/userprofilemiddleware.py
+++ b/middleware/userprofilemiddleware.py
@@ -1,5 +1,5 @@
from django.utils.deprecation import MiddlewareMixin
-from users.models import UserProfile
+from services.users.models import UserProfile
class UserProfileMiddleware(MiddlewareMixin):
diff --git a/users/__init__.py b/services/users/__init__.py
index e69de29b..e69de29b 100644
--- a/users/__init__.py
+++ b/services/users/__init__.py
diff --git a/users/accountFunctions.py b/services/users/accountFunctions.py
index 38bc7099..036b549a 100644
--- a/users/accountFunctions.py
+++ b/services/users/accountFunctions.py
@@ -3,7 +3,7 @@ import uuid
from django.utils import timezone
-from users.models import TokenStore, UserProfile
+from services.users.models import TokenStore, UserProfile
def generate_token():
@@ -12,6 +12,7 @@ def generate_token():
print(uid, token)
return uid, token
+
def store_token(token_type, user, email=None):
previous_tokens = TokenStore.objects.filter(user=user, token_type=token_type)
if previous_tokens.exists():
@@ -28,21 +29,31 @@ def store_token(token_type, user, email=None):
token_store.save()
return uid, token
+
def verify_token(token_type, uid, token, hold_verification=False):
try:
- token_store = TokenStore.objects.get(token_type=token_type, uid=uid, token=token)
- if token_store.expires > timezone.now() and not token_store.verified and token_store.token_type == token_type and token_store.uid == uid and token_store.token == token:
+ token_store = TokenStore.objects.get(
+ token_type=token_type, uid=uid, token=token
+ )
+ if (
+ token_store.expires > timezone.now()
+ and not token_store.verified
+ and token_store.token_type == token_type
+ and token_store.uid == uid
+ and token_store.token == token
+ ):
if hold_verification:
return token_store
token_store.verified = True
-
+
if token_type == "verifyemail":
- UserProfile.objects.filter(user=token_store.user).update(email_verified=True)
+ UserProfile.objects.filter(user=token_store.user).update(
+ email_verified=True
+ )
token_store.save()
return token_store
except TokenStore.DoesNotExist:
return None
- \ No newline at end of file
diff --git a/users/admin.py b/services/users/admin.py
index 0f1d5fdb..0f1d5fdb 100644
--- a/users/admin.py
+++ b/services/users/admin.py
diff --git a/services/users/apps.py b/services/users/apps.py
new file mode 100644
index 00000000..dafff467
--- /dev/null
+++ b/services/users/apps.py
@@ -0,0 +1,6 @@
+from django.apps import AppConfig
+
+
+class UsersConfig(AppConfig):
+ default_auto_field = "django.db.models.BigAutoField"
+ name = "services.users"
diff --git a/users/forms.py b/services/users/forms.py
index c2b80732..39d503fc 100644
--- a/users/forms.py
+++ b/services/users/forms.py
@@ -9,7 +9,7 @@ from django.template.loader import render_to_string
from django.utils.html import strip_tags
from apps.blog.context_processors import avatar_list
-from users.models import UserProfile
+from services.users.models import UserProfile
from .accountFunctions import store_token
from .mail_send import send_email
diff --git a/users/mail_send.py b/services/users/mail_send.py
index df837a32..df837a32 100644
--- a/users/mail_send.py
+++ b/services/users/mail_send.py
diff --git a/users/migrations/0001_initial.py b/services/users/migrations/0001_initial.py
index a8a78c6b..a8a78c6b 100644
--- a/users/migrations/0001_initial.py
+++ b/services/users/migrations/0001_initial.py
diff --git a/users/migrations/0002_userprofile_email_verified.py b/services/users/migrations/0002_userprofile_email_verified.py
index ca89b815..ca89b815 100644
--- a/users/migrations/0002_userprofile_email_verified.py
+++ b/services/users/migrations/0002_userprofile_email_verified.py
diff --git a/users/migrations/0003_captchastore.py b/services/users/migrations/0003_captchastore.py
index 9aebc0aa..9aebc0aa 100644
--- a/users/migrations/0003_captchastore.py
+++ b/services/users/migrations/0003_captchastore.py
diff --git a/users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py b/services/users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py
index 1dd16bcc..1dd16bcc 100644
--- a/users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py
+++ b/services/users/migrations/0004_remove_captchastore_id_alter_captchastore_csrf_token.py
diff --git a/users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py b/services/users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py
index bc3d86e5..bc3d86e5 100644
--- a/users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py
+++ b/services/users/migrations/0005_captchastore_id_alter_captchastore_csrf_token.py
diff --git a/users/migrations/0006_delete_captchastore.py b/services/users/migrations/0006_delete_captchastore.py
index f324ff2f..f324ff2f 100644
--- a/users/migrations/0006_delete_captchastore.py
+++ b/services/users/migrations/0006_delete_captchastore.py
diff --git a/users/migrations/0007_captchastore.py b/services/users/migrations/0007_captchastore.py
index 15ac458a..15ac458a 100644
--- a/users/migrations/0007_captchastore.py
+++ b/services/users/migrations/0007_captchastore.py
diff --git a/users/migrations/0008_remove_userprofile_gravatar_email_and_more.py b/services/users/migrations/0008_remove_userprofile_gravatar_email_and_more.py
index 07f33320..07f33320 100644
--- a/users/migrations/0008_remove_userprofile_gravatar_email_and_more.py
+++ b/services/users/migrations/0008_remove_userprofile_gravatar_email_and_more.py
diff --git a/users/migrations/0009_delete_captchastore.py b/services/users/migrations/0009_delete_captchastore.py
index dbde60c8..dbde60c8 100644
--- a/users/migrations/0009_delete_captchastore.py
+++ b/services/users/migrations/0009_delete_captchastore.py
diff --git a/users/migrations/0010_userprofile_blinkie_url.py b/services/users/migrations/0010_userprofile_blinkie_url.py
index 06f5e53c..06f5e53c 100644
--- a/users/migrations/0010_userprofile_blinkie_url.py
+++ b/services/users/migrations/0010_userprofile_blinkie_url.py
diff --git a/users/migrations/0011_tokenstore.py b/services/users/migrations/0011_tokenstore.py
index f0bf9330..f0bf9330 100644
--- a/users/migrations/0011_tokenstore.py
+++ b/services/users/migrations/0011_tokenstore.py
diff --git a/users/migrations/0012_alter_tokenstore_expires.py b/services/users/migrations/0012_alter_tokenstore_expires.py
index 4b3481fd..4b3481fd 100644
--- a/users/migrations/0012_alter_tokenstore_expires.py
+++ b/services/users/migrations/0012_alter_tokenstore_expires.py
diff --git a/users/migrations/__init__.py b/services/users/migrations/__init__.py
index e69de29b..e69de29b 100644
--- a/users/migrations/__init__.py
+++ b/services/users/migrations/__init__.py
diff --git a/users/models.py b/services/users/models.py
index f11f2f46..f11f2f46 100644
--- a/users/models.py
+++ b/services/users/models.py
diff --git a/users/templates/email_change_verification_email.html b/services/users/templates/email_change_verification_email.html
index f6f9b127..f6f9b127 100644
--- a/users/templates/email_change_verification_email.html
+++ b/services/users/templates/email_change_verification_email.html
diff --git a/users/templates/reset_password_email.html b/services/users/templates/reset_password_email.html
index f9651a13..f9651a13 100644
--- a/users/templates/reset_password_email.html
+++ b/services/users/templates/reset_password_email.html
diff --git a/users/templates/verification_email.html b/services/users/templates/verification_email.html
index 06e91a79..06e91a79 100644
--- a/users/templates/verification_email.html
+++ b/services/users/templates/verification_email.html
diff --git a/users/tests.py b/services/users/tests.py
index 7ce503c2..7ce503c2 100644
--- a/users/tests.py
+++ b/services/users/tests.py
diff --git a/users/tokens.py b/services/users/tokens.py
index 05d73362..05d73362 100644
--- a/users/tokens.py
+++ b/services/users/tokens.py
diff --git a/users/urls.py b/services/users/urls.py
index b7081e42..b7081e42 100644
--- a/users/urls.py
+++ b/services/users/urls.py
diff --git a/users/views.py b/services/users/views.py
index 5dba135b..5dba135b 100644
--- a/users/views.py
+++ b/services/users/views.py
diff --git a/static/css/shared/core.css b/static/css/shared/core.css
index 02d41657..094f9555 100644
--- a/static/css/shared/core.css
+++ b/static/css/shared/core.css
@@ -1,11 +1,13 @@
/* Reset and Base Styles */
-@font-face {
+@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@100;300;400;500;700;800;900&display=swap');
+
+/* @font-face {
font-family: 'Klee';
src: url('../../fonts/KleeOne-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
font-display: swap
-}
+} */
@font-face {
font-family: 'SweetFairy';
@@ -39,7 +41,7 @@ body {
body,
textarea,
input {
- font-family: 'Klee';
+ font-family: 'M PLUS Rounded 1c';
font-size: 12px;
font-weight: 400;
}
@@ -259,6 +261,63 @@ html[lang='ja'] .navigation-title {
margin-right: 8px;
}
+.user-stats-area {
+ margin: 12px 0px 0px 0px;
+ background-color: #f4f1e90f;
+ padding: 8px 0px;
+ border-radius: 8px;
+}
+
+.stats-profile-image {
+ width: 120px;
+ height: 120px;
+ margin: 4px auto;
+ display: block;
+}
+
+.stats-username,
+.stats-bio {
+ margin: 4px 0px;
+}
+
+.stats-bio {
+ padding: 4px 0px;
+ border-top: 1px solid #fff;
+ border-bottom: 1px solid #fff;
+}
+
+.user-stats {
+ display: flex;
+ justify-content: space-between;
+ padding: 4px;
+ background-color: #6446858a;
+}
+
+.user-stats:nth-child(odd) {
+ background-color: #54266a85;
+}
+
+.stat-links a {
+ display: block;
+ padding: 4px;
+}
+
+.stat-links a::before {
+ content: '>';
+ margin-right: 4px;
+}
+
+.stat-value {
+ display: flex;
+ align-items: center;
+ gap: 2px;
+}
+
+.stat-value img {
+ width: 12px;
+ height: 12px;
+}
+
/* Sidebar Search Bar */
#search-area {
diff --git a/static/css/shared/login-area.css b/static/css/shared/login-area.css
index cb3d1a07..b2e86506 100644
--- a/static/css/shared/login-area.css
+++ b/static/css/shared/login-area.css
@@ -152,7 +152,7 @@
.user-avatar {
width: 72px;
height: 72px;
- border: solid 2px #8d8dff;
+ /* border: solid 2px #8d8dff; */
padding: 4px;
position: absolute;
bottom: 0;
@@ -162,4 +162,6 @@
.user-avatar img {
width: 100%;
height: 100%;
+ border-radius: 50%;
+
} \ No newline at end of file
diff --git a/static/images/core/icons/coin.png b/static/images/core/icons/coin.png
new file mode 100644
index 00000000..4be6fe09
--- /dev/null
+++ b/static/images/core/icons/coin.png
Binary files differ
diff --git a/templates/en/core/home.html b/templates/en/core/home.html
index 281560c2..8075b6b1 100644
--- a/templates/en/core/home.html
+++ b/templates/en/core/home.html
@@ -50,7 +50,6 @@
<div class="recent-weblogs">
{% include 'partials/weblog_list.html' with posts=recent_weblogs %}
</div>
-
<h1 class="section-title">Recent Weeb Degenerecy</h1>
<div class="recent-anime">
{% for anime in recent_mal_activity.anime %}
@@ -68,6 +67,7 @@
</a>
{% endfor %}
</div>
+<div class="pamphlet pamphlet-banner"></div>
{% endblock %}
{% block scripts %}
<script src="{% static 'js/libs/marquee.js' %}"></script>
diff --git a/templates/ja/core/home.html b/templates/ja/core/home.html
index 20d8747e..6d566a93 100644
--- a/templates/ja/core/home.html
+++ b/templates/ja/core/home.html
@@ -67,6 +67,7 @@
</a>
{% endfor %}
</div>
+<div class="pamphlet pamphlet-banner"></div>
{% endblock %}
{% block scripts %}
<script src="{% static 'js/libs/marquee.js' %}"></script>
diff --git a/templates/shared/right_sidebar.html b/templates/shared/right_sidebar.html
index 10c5c96b..3a071310 100644
--- a/templates/shared/right_sidebar.html
+++ b/templates/shared/right_sidebar.html
@@ -45,6 +45,48 @@
</div>
</div>
<div class="pamphlet pamphlet-big"></div>
+
+ {% if user.is_authenticated %}
+ <div class="user-stats-area">
+ <img src="{% static 'images/avatars/' %}{{ user.profile.avatar_url }}.gif" class="stats-profile-image" alt="{{ user.first_name }}'s Avatar">
+ <h2 class="stats-username"><a href="#">{{ user.first_name }} {{ user.last_name }}</a></h2>
+ <p class="stats-bio">{{ user.profile.bio|linebreaksbr }}</p>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}経験値{% else %}XP{% endif %}</p>
+ <p class="stat-value">{{ user.profile.experience }}0 / 1000</p>
+ </div>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}レベル{% else %}Level{% endif %}</p>
+ <p class="stat-value">{{ user.profile.level }}1</p>
+ </div>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}残高{% else %}Balance{% endif %}</p>
+ <p class="stat-value">
+ <span>{{ user.profile.balance }}0</span>
+ <img src="{% static 'images/core/icons/coin.png' %}" alt="Coin Icon" />
+ </p>
+ </div>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}ジャーナルエントリー{% else %}Journal Entries{% endif %}</p>
+ <p class="stat-value">{{ user.profile.journal_entries }}0</p>
+ </div>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}ジャーナル連続記録{% else %}Journal Streak{% endif %}</p>
+ <p class="stat-value">{{ user.profile.journal_streak }}0 days</p>
+ </div>
+ <div class="user-stats">
+ <p class="stat-name">{% if request.LANGUAGE_CODE == 'ja' %}ウェブログ投稿{% else %}Weblog Posts{% endif %}</p>
+ <p class="stat-value">{{ user.profile.weblog_posts }}0</p>
+ </div>
+ <div class="stat-links">
+ <a href="#">{% if request.LANGUAGE_CODE == 'ja' %}ドレッシングルーム{% else %}Dressing Room{% endif %}</a>
+ <a href="#">{% if request.LANGUAGE_CODE == 'ja' %}実績{% else %}Achievements{% endif %}</a>
+ <a href="#">{% if request.LANGUAGE_CODE == 'ja' %}ウェブログ{% else %}Weblog{% endif %}</a>
+ </div>
+ </div>
+
+ {% endif %}
+
<div class="navigation-links">
<div class="navigation-title-container">
<h1 class="navigation-title">{% if request.LANGUAGE_CODE == 'ja' %}ザ・マトリックス{% else %}The Matrix{% endif %}
diff --git a/thatcomputerscientist/settings.py b/thatcomputerscientist/settings.py
index 3db548c0..f8cd493e 100644
--- a/thatcomputerscientist/settings.py
+++ b/thatcomputerscientist/settings.py
@@ -78,7 +78,9 @@ INSTALLED_APPS = [
"apps.core",
"apps.administration",
"apps.blog",
- "users",
+ "services.users",
+ "services.stream",
+ "services.pamphlet",
"blog_admin",
"dev_status",
"ignis",
diff --git a/thatcomputerscientist/urls.py b/thatcomputerscientist/urls.py
index 835ad954..18c4dcbe 100644
--- a/thatcomputerscientist/urls.py
+++ b/thatcomputerscientist/urls.py
@@ -43,6 +43,7 @@ urlpatterns = [
path("weblog/", include("apps.blog.urls", namespace="weblog")),
path("services/stream/", include("services.stream.urls", namespace="stream")),
path("services/pamphlet", include("services.pamphlet.urls", namespace="pamphlet")),
+ path("services/auth/", include("services.users.urls", namespace="auth")),
path("admin/", include("apps.administration.urls", namespace="administration")),
path("administration-corner/", admin.site.urls),
# path('users', include('users.urls', namespace='users')),
diff --git a/users/apps.py b/users/apps.py
deleted file mode 100644
index 72b14010..00000000
--- a/users/apps.py
+++ /dev/null
@@ -1,6 +0,0 @@
-from django.apps import AppConfig
-
-
-class UsersConfig(AppConfig):
- default_auto_field = 'django.db.models.BigAutoField'
- name = 'users'