diff --git a/vrobbler/apps/books/migrations/0002_book_author_name_book_author_openlibrary_id.py b/vrobbler/apps/books/migrations/0002_book_author_name_book_author_openlibrary_id.py new file mode 100644 index 0000000..1529227 --- /dev/null +++ b/vrobbler/apps/books/migrations/0002_book_author_name_book_author_openlibrary_id.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.5 on 2023-03-06 05:29 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("books", "0001_initial"), + ] + + operations = [ + migrations.AddField( + model_name="book", + name="author_name", + field=models.CharField(blank=True, max_length=255, null=True), + ), + migrations.AddField( + model_name="book", + name="author_openlibrary_id", + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/vrobbler/apps/books/migrations/0003_book_cover.py b/vrobbler/apps/books/migrations/0003_book_cover.py new file mode 100644 index 0000000..8549a9d --- /dev/null +++ b/vrobbler/apps/books/migrations/0003_book_cover.py @@ -0,0 +1,20 @@ +# Generated by Django 4.1.5 on 2023-03-06 05:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("books", "0002_book_author_name_book_author_openlibrary_id"), + ] + + operations = [ + migrations.AddField( + model_name="book", + name="cover", + field=models.ImageField( + blank=True, null=True, upload_to="books/covers/" + ), + ), + ] diff --git a/vrobbler/apps/books/urls.py b/vrobbler/apps/books/urls.py new file mode 100644 index 0000000..6638eea --- /dev/null +++ b/vrobbler/apps/books/urls.py @@ -0,0 +1,19 @@ +from django.urls import path +from books import views + +app_name = "books" + + +urlpatterns = [ + path("book/", views.BookListView.as_view(), name="book_list"), + path( + "book//", + views.BookDetailView.as_view(), + name="book_detail", + ), + path( + "author//", + views.AuthorDetailView.as_view(), + name="author_detail", + ), +] diff --git a/vrobbler/apps/books/views.py b/vrobbler/apps/books/views.py new file mode 100644 index 0000000..d4df0a8 --- /dev/null +++ b/vrobbler/apps/books/views.py @@ -0,0 +1,17 @@ +from django.views import generic +from books.models import Book, Author + + +class BookListView(generic.ListView): + model = Book + paginate_by = 20 + + +class BookDetailView(generic.DetailView): + model = Book + slug_field = "uuid" + + +class AuthorDetailView(generic.DetailView): + model = Author + slug_field = "uuid" diff --git a/vrobbler/apps/scrobbles/migrations/0027_remove_scrobble_videogame_minutes_played_and_more.py b/vrobbler/apps/scrobbles/migrations/0027_remove_scrobble_videogame_minutes_played_and_more.py new file mode 100644 index 0000000..9a90cab --- /dev/null +++ b/vrobbler/apps/scrobbles/migrations/0027_remove_scrobble_videogame_minutes_played_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.1.5 on 2023-03-06 02:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("scrobbles", "0026_scrobble_video_game"), + ] + + operations = [ + migrations.RemoveField( + model_name="scrobble", + name="videogame_minutes_played", + ), + migrations.AlterField( + model_name="scrobble", + name="playback_position", + field=models.CharField(blank=True, max_length=10, null=True), + ), + ] diff --git a/vrobbler/apps/scrobbles/migrations/0028_scrobble_video_game_minutes_played.py b/vrobbler/apps/scrobbles/migrations/0028_scrobble_video_game_minutes_played.py new file mode 100644 index 0000000..0529bdc --- /dev/null +++ b/vrobbler/apps/scrobbles/migrations/0028_scrobble_video_game_minutes_played.py @@ -0,0 +1,21 @@ +# Generated by Django 4.1.5 on 2023-03-06 05:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ( + "scrobbles", + "0027_remove_scrobble_videogame_minutes_played_and_more", + ), + ] + + operations = [ + migrations.AddField( + model_name="scrobble", + name="video_game_minutes_played", + field=models.IntegerField(blank=True, null=True), + ), + ] diff --git a/vrobbler/apps/scrobbles/static/images/hltb.webp b/vrobbler/apps/scrobbles/static/images/hltb.webp new file mode 100644 index 0000000..5a566e8 Binary files /dev/null and b/vrobbler/apps/scrobbles/static/images/hltb.webp differ diff --git a/vrobbler/apps/scrobbles/static/images/igdb-logo.png b/vrobbler/apps/scrobbles/static/images/igdb-logo.png new file mode 100644 index 0000000..2030358 Binary files /dev/null and b/vrobbler/apps/scrobbles/static/images/igdb-logo.png differ diff --git a/vrobbler/apps/videogames/migrations/0006_videogame_summary_alter_videogame_platforms.py b/vrobbler/apps/videogames/migrations/0006_videogame_summary_alter_videogame_platforms.py new file mode 100644 index 0000000..0f522c9 --- /dev/null +++ b/vrobbler/apps/videogames/migrations/0006_videogame_summary_alter_videogame_platforms.py @@ -0,0 +1,23 @@ +# Generated by Django 4.1.5 on 2023-03-06 02:52 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("videogames", "0005_rename_platform_videogame_platforms"), + ] + + operations = [ + migrations.AddField( + model_name="videogame", + name="summary", + field=models.TextField(blank=True, null=True), + ), + migrations.AlterField( + model_name="videogame", + name="platforms", + field=models.ManyToManyField(to="videogames.videogameplatform"), + ), + ] diff --git a/vrobbler/apps/videogames/templatetags/__init__.py b/vrobbler/apps/videogames/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/vrobbler/apps/videogames/templatetags/naturalduration.py b/vrobbler/apps/videogames/templatetags/naturalduration.py new file mode 100644 index 0000000..6c7a98b --- /dev/null +++ b/vrobbler/apps/videogames/templatetags/naturalduration.py @@ -0,0 +1,16 @@ +from django import template + +register = template.Library() + + +@register.filter +def natural_duration(value): + value = int(value) + hours = int(value / 60) + minutes = value - (hours * 60) + value_str = "" + if minutes: + value_str = f"{minutes} minutes" + if hours: + value_str = f"{hours} hours, " + value_str + return value_str diff --git a/vrobbler/templates/books/book_detail.html b/vrobbler/templates/books/book_detail.html new file mode 100644 index 0000000..467a8e0 --- /dev/null +++ b/vrobbler/templates/books/book_detail.html @@ -0,0 +1,57 @@ +{% extends "base_list.html" %} +{% load mathfilters %} +{% load static %} +{% load naturalduration %} + +{% block title %}{{object.title}}{% endblock %} + +{% block lists %} + +
+ + {% if object.cover%} +

+ +

+ {% endif %} +
+ {% if object.summary %} +

{{object.summary|safe|linebreaks|truncatewords:160}}

+
+ {% endif %} +

+ + +

+
+
+
+

{{object.scrobble_set.count}} scrobbles

+

Start playing

+
+
+
+

Last scrobbles

+
+ + + + + + + + + + {% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %} + + + + + + {% endfor %} + +
DateDurationAuthors
{{scrobble.timestamp}}{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position|natural_duration}}{% endif %}{% for author in scrobble.book.authors.all %}{{author}}{% if not forloop.last %}, {% endif %}{% endfor %}
+
+
+
+{% endblock %} diff --git a/vrobbler/templates/videogames/videogame_detail.html b/vrobbler/templates/videogames/videogame_detail.html new file mode 100644 index 0000000..c43ba81 --- /dev/null +++ b/vrobbler/templates/videogames/videogame_detail.html @@ -0,0 +1,57 @@ +{% extends "base_list.html" %} +{% load mathfilters %} +{% load static %} +{% load naturalduration %} + +{% block title %}{{object.title}}{% endblock %} + +{% block lists %} + +
+ + {% if object.hltb_cover%} +

+ +

+ {% endif %} +
+ {% if object.summary %} +

{{object.summary|safe|linebreaks|truncatewords:160}}

+
+ {% endif %} +

+ + +

+
+
+
+

{{object.scrobble_set.count}} scrobbles

+

Start playing

+
+
+
+

Last scrobbles

+
+ + + + + + + + + + {% for scrobble in object.scrobble_set.all|dictsortreversed:"timestamp" %} + + + + + + {% endfor %} + +
DateDurationPlatforms
{{scrobble.timestamp}}{% if scrobble.in_progress %}Now playing{% else %}{{scrobble.playback_position|natural_duration}}{% endif %}{% for platform in scrobble.video_game.platforms.all %}{{platform}}{% if not forloop.last %}, {% endif %}{% endfor %}
+
+
+
+{% endblock %}