diff --git a/akarpov/blog/migrations/0007_alter_comment_options_alter_commentrating_options_and_more.py b/akarpov/blog/migrations/0007_alter_comment_options_alter_commentrating_options_and_more.py new file mode 100644 index 0000000..9ee9640 --- /dev/null +++ b/akarpov/blog/migrations/0007_alter_comment_options_alter_commentrating_options_and_more.py @@ -0,0 +1,33 @@ +# Generated by Django 4.2.2 on 2023-07-01 10:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("blog", "0006_post_public"), + ] + + operations = [ + migrations.AlterModelOptions( + name="comment", + options={"ordering": ["-rating", "-created"], "verbose_name": "Comment"}, + ), + migrations.AlterModelOptions( + name="commentrating", + options={"verbose_name": "Comment rating"}, + ), + migrations.AlterModelOptions( + name="post", + options={"ordering": ["-created"], "verbose_name": "Post"}, + ), + migrations.AlterModelOptions( + name="postrating", + options={"verbose_name": "Post rating"}, + ), + migrations.AlterModelOptions( + name="tag", + options={"verbose_name": "Tag"}, + ), + ] diff --git a/akarpov/blog/models.py b/akarpov/blog/models.py index 682c57c..3d581ad 100644 --- a/akarpov/blog/models.py +++ b/akarpov/blog/models.py @@ -5,12 +5,13 @@ from django.urls import reverse from akarpov.common.models import BaseImageModel -from akarpov.tools.shortener.models import ShortLink +from akarpov.tools.shortener.models import ShortLinkModel from akarpov.users.models import User +from akarpov.users.services.history import UserHistoryModel from akarpov.utils.string import cleanhtml -class Post(BaseImageModel, ShortLink): +class Post(BaseImageModel, ShortLinkModel, UserHistoryModel): title = models.CharField(max_length=100, blank=False) body = RichTextUploadingField(blank=False) @@ -64,21 +65,28 @@ def get_absolute_url(self): return reverse("blog:post", kwargs={"slug": self.slug}) class Meta: + verbose_name = "Post" ordering = ["-created"] class SlugMeta: slug_length = 3 -class Tag(models.Model): +class Tag(UserHistoryModel): name = models.CharField(max_length=20, unique=True) color = ColorField(blank=True, default="#FF0000") def __str__(self): return self.name + def get_absolute_url(self): + return reverse("blog:post_list") + f"?tag={self.name}" -class PostRating(models.Model): + class Meta: + verbose_name = "Tag" + + +class PostRating(UserHistoryModel): user = models.ForeignKey( User, on_delete=models.CASCADE, related_name="post_ratings" ) @@ -86,6 +94,9 @@ class PostRating(models.Model): vote_up = models.BooleanField(blank=False) + def get_absolute_url(self): + return self.post.get_absolute_url() + def __str__(self): return ( f"{self.user}'s vote up on {self.post.title}" @@ -94,10 +105,11 @@ def __str__(self): ) class Meta: + verbose_name = "Post rating" unique_together = ["user", "post"] -class Comment(models.Model): +class Comment(UserHistoryModel): parent = models.ForeignKey("self", blank=True, null=True, on_delete=models.CASCADE) post = models.ForeignKey(Post, on_delete=models.CASCADE, related_name="comments") author = models.ForeignKey(User, on_delete=models.CASCADE, related_name="comments") @@ -107,14 +119,18 @@ class Comment(models.Model): rating = models.IntegerField(default=0) + def get_absolute_url(self): + return self.post.get_absolute_url() + f"#{self.id}" + def __str__(self): return f"{self.author.username}'s comment on {self.post.title}" class Meta: + verbose_name = "Comment" ordering = ["-rating", "-created"] -class CommentRating(models.Model): +class CommentRating(UserHistoryModel): comment = models.ForeignKey( Comment, on_delete=models.CASCADE, related_name="ratings" ) @@ -127,5 +143,9 @@ class CommentRating(models.Model): def __str__(self): return f"{self.user}'s vote up" if self.vote_up else f"{self.user}'s vote down" + def get_absolute_url(self): + return self.comment.get_absolute_url() + class Meta: + verbose_name = "Comment rating" unique_together = ["comment", "user"] diff --git a/akarpov/files/migrations/0024_alter_file_options_alter_filereport_options_and_more.py b/akarpov/files/migrations/0024_alter_file_options_alter_filereport_options_and_more.py new file mode 100644 index 0000000..ebecd72 --- /dev/null +++ b/akarpov/files/migrations/0024_alter_file_options_alter_filereport_options_and_more.py @@ -0,0 +1,25 @@ +# Generated by Django 4.2.2 on 2023-07-01 10:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("files", "0023_rename_download_basefileitem_downloads_and_more"), + ] + + operations = [ + migrations.AlterModelOptions( + name="file", + options={"verbose_name": "File"}, + ), + migrations.AlterModelOptions( + name="filereport", + options={"verbose_name": "File report"}, + ), + migrations.AlterModelOptions( + name="folder", + options={"verbose_name": "Folder"}, + ), + ] diff --git a/akarpov/files/models.py b/akarpov/files/models.py index 8f7467e..da1e747 100644 --- a/akarpov/files/models.py +++ b/akarpov/files/models.py @@ -19,7 +19,8 @@ from polymorphic.models import PolymorphicModel from akarpov.files.services.files import trash_file_upload, user_unique_file_upload -from akarpov.tools.shortener.models import ShortLink +from akarpov.tools.shortener.models import ShortLinkModel +from akarpov.users.services.history import UserHistoryModel class BaseFileItem(PolymorphicModel): @@ -59,7 +60,7 @@ def save(self, *args, **kwargs): super().save(*args, **kwargs) -class File(BaseFileItem, TimeStampedModel, ShortLink): +class File(BaseFileItem, TimeStampedModel, ShortLinkModel, UserHistoryModel): """model to store user's files""" private = BooleanField(default=True) @@ -102,8 +103,11 @@ def get_absolute_url(self): def __str__(self): return f"file: {self.name}" + class Meta: + verbose_name = "File" -class Folder(BaseFileItem, ShortLink): + +class Folder(BaseFileItem, ShortLinkModel, UserHistoryModel): name = CharField(max_length=100) slug = SlugField(max_length=20, blank=True) private = BooleanField(default=True) @@ -118,6 +122,9 @@ def get_absolute_url(self): def __str__(self): return f"folder: {self.name}" + class Meta: + verbose_name = "Folder" + class FileInTrash(TimeStampedModel): name = CharField(max_length=200, blank=True) @@ -132,5 +139,11 @@ class FileReport(Model): created = DateTimeField(auto_now_add=True) file = ForeignKey("files.File", related_name="reports", on_delete=CASCADE) + class Meta: + verbose_name = "File report" + + def get_absolute_url(self): + return self.file.get_absolute_url() + def __str__(self): return f"report on {self.file}" diff --git a/akarpov/gallery/migrations/0003_alter_collection_options_alter_image_options.py b/akarpov/gallery/migrations/0003_alter_collection_options_alter_image_options.py new file mode 100644 index 0000000..300ead1 --- /dev/null +++ b/akarpov/gallery/migrations/0003_alter_collection_options_alter_image_options.py @@ -0,0 +1,21 @@ +# Generated by Django 4.2.2 on 2023-07-01 10:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("gallery", "0002_image_extra_data_image_image_city_and_more"), + ] + + operations = [ + migrations.AlterModelOptions( + name="collection", + options={"verbose_name": "Collection"}, + ), + migrations.AlterModelOptions( + name="image", + options={"verbose_name": "Image"}, + ), + ] diff --git a/akarpov/gallery/models.py b/akarpov/gallery/models.py index 0af6fe2..41e8292 100644 --- a/akarpov/gallery/models.py +++ b/akarpov/gallery/models.py @@ -4,11 +4,12 @@ from location_field.models.plain import PlainLocationField from akarpov.common.models import BaseImageModel -from akarpov.tools.shortener.models import ShortLink +from akarpov.tools.shortener.models import ShortLinkModel +from akarpov.users.services.history import UserHistoryModel from akarpov.utils.files import user_file_upload_mixin -class Collection(TimeStampedModel, ShortLink): +class Collection(TimeStampedModel, ShortLinkModel, UserHistoryModel): name = models.CharField(max_length=250, blank=True) description = models.TextField() public = models.BooleanField(default=False) @@ -22,8 +23,11 @@ def get_absolute_url(self): def __str__(self): return self.name + class Meta: + verbose_name = "Collection" -class Image(TimeStampedModel, ShortLink, BaseImageModel): + +class Image(TimeStampedModel, ShortLinkModel, BaseImageModel, UserHistoryModel): collection = models.ForeignKey( "Collection", related_name="images", on_delete=models.CASCADE ) @@ -46,8 +50,11 @@ def get_absolute_url(self): def __str__(self): return self.image.name + class Meta: + verbose_name = "Image" -class Tag(ShortLink): + +class Tag(ShortLinkModel): name = models.CharField(max_length=255, null=True, blank=True) def get_absolute_url(self): diff --git a/akarpov/music/apps.py b/akarpov/music/apps.py index 539024e..bdd37e7 100644 --- a/akarpov/music/apps.py +++ b/akarpov/music/apps.py @@ -2,7 +2,7 @@ class MusicConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" + verbose_name = "Music" name = "akarpov.music" def ready(self): diff --git a/akarpov/music/migrations/0002_alter_playlist_options.py b/akarpov/music/migrations/0002_alter_playlist_options.py new file mode 100644 index 0000000..30301db --- /dev/null +++ b/akarpov/music/migrations/0002_alter_playlist_options.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.2 on 2023-07-01 10:43 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("music", "0001_initial"), + ] + + operations = [ + migrations.AlterModelOptions( + name="playlist", + options={"verbose_name": "Playlist"}, + ), + ] diff --git a/akarpov/music/models.py b/akarpov/music/models.py index 5ad435b..c77057e 100644 --- a/akarpov/music/models.py +++ b/akarpov/music/models.py @@ -2,10 +2,11 @@ from django.urls import reverse from akarpov.common.models import BaseImageModel -from akarpov.tools.shortener.models import ShortLink +from akarpov.tools.shortener.models import ShortLinkModel +from akarpov.users.services.history import UserHistoryModel -class Author(BaseImageModel, ShortLink): +class Author(BaseImageModel, ShortLinkModel): name = models.CharField(max_length=200) link = models.URLField(blank=True) @@ -16,7 +17,7 @@ def __str__(self): return self.name -class Album(BaseImageModel, ShortLink): +class Album(BaseImageModel, ShortLinkModel): name = models.CharField(max_length=200) link = models.URLField(blank=True) @@ -27,7 +28,7 @@ def __str__(self): return self.name -class Song(BaseImageModel, ShortLink): +class Song(BaseImageModel, ShortLinkModel): link = models.URLField(blank=True) length = models.IntegerField(null=True) played = models.IntegerField(default=0) @@ -50,7 +51,7 @@ class SlugMeta: slug_length = 10 -class Playlist(ShortLink): +class Playlist(ShortLinkModel, UserHistoryModel): name = models.CharField(max_length=200) private = models.BooleanField(default=False) creator = models.ForeignKey( @@ -64,6 +65,9 @@ def get_absolute_url(self): def get_songs(self): return self.songs.all().values("song") + class Meta: + verbose_name = "Playlist" + class PlaylistSong(models.Model): order = models.IntegerField() diff --git a/akarpov/pipeliner/apps.py b/akarpov/pipeliner/apps.py index 40d8076..5c1cf92 100644 --- a/akarpov/pipeliner/apps.py +++ b/akarpov/pipeliner/apps.py @@ -2,5 +2,5 @@ class PipelinerConfig(AppConfig): - default_auto_field = "django.db.models.BigAutoField" + verbose_name = "Pipeliner" name = "akarpov.pipeliner" diff --git a/akarpov/templates/base.html b/akarpov/templates/base.html index 74a2779..1875cf6 100644 --- a/akarpov/templates/base.html +++ b/akarpov/templates/base.html @@ -85,6 +85,7 @@