This repository has been archived by the owner on Jan 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #207 from mmoomocow/DCS-080
DCS-080 Informative site messages
- Loading branch information
Showing
8 changed files
with
99 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,15 @@ | ||
from django.apps import AppConfig | ||
from django.contrib.auth.signals import user_logged_in | ||
|
||
|
||
class UsersConfig(AppConfig): | ||
"""AppConfig for the Users app.""" | ||
|
||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "users" | ||
|
||
def ready(self): | ||
"""Import signals.""" | ||
import users.signals | ||
|
||
user_logged_in.connect(users.signals.update_last_visit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 4.2.1 on 2023-07-31 23:37 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0003_alter_user_managers"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="user", | ||
name="last_visit", | ||
field=models.DateTimeField( | ||
blank=True, null=True, verbose_name="Last Visit" | ||
), | ||
), | ||
] |
30 changes: 30 additions & 0 deletions
30
users/migrations/0005_remove_user_last_visit_user_previous_login_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Generated by Django 4.2.1 on 2023-08-01 00:06 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("users", "0004_user_last_visit"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="user", | ||
name="last_visit", | ||
), | ||
migrations.AddField( | ||
model_name="user", | ||
name="previous_login", | ||
field=models.DateTimeField( | ||
blank=True, null=True, verbose_name="Previous Login" | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="user", | ||
name="recent_login", | ||
field=models.DateTimeField( | ||
blank=True, null=True, verbose_name="Most Recent Login" | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.utils import timezone | ||
|
||
from .models import User | ||
|
||
|
||
def update_last_visit(sender, **kwargs): # skipcq: PYL-W0613 | ||
"""Update the last viewed time.""" | ||
user: User = kwargs["user"] | ||
user.previous_login = user.recent_login | ||
user.recent_login = timezone.now() | ||
user.save() |