mirror of
https://github.com/daniviga/django-ram.git
synced 2025-12-26 07:18:32 +01:00
More UI improvements and fix a regression on manufacturer filtering
This commit is contained in:
@@ -475,6 +475,7 @@ class MagazineAdmin(SortableAdminBase, admin.ModelAdmin):
|
||||
"fields": (
|
||||
"published",
|
||||
"name",
|
||||
"website",
|
||||
"publisher",
|
||||
"ISBN",
|
||||
"language",
|
||||
|
||||
18
ram/bookshelf/migrations/0027_magazine_website.py
Normal file
18
ram/bookshelf/migrations/0027_magazine_website.py
Normal file
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 6.0 on 2025-12-12 14:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("bookshelf", "0026_alter_basebook_language_alter_magazine_image_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="magazine",
|
||||
name="website",
|
||||
field=models.URLField(blank=True),
|
||||
),
|
||||
]
|
||||
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
import shutil
|
||||
from urllib.parse import urlparse
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
@@ -169,6 +170,7 @@ class Catalog(BaseBook):
|
||||
class Magazine(BaseModel):
|
||||
name = models.CharField(max_length=200)
|
||||
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
|
||||
website = models.URLField(blank=True)
|
||||
ISBN = models.CharField(max_length=17, blank=True) # 13 + dashes
|
||||
image = models.ImageField(
|
||||
blank=True,
|
||||
@@ -205,6 +207,10 @@ class Magazine(BaseModel):
|
||||
kwargs={"uuid": self.uuid}
|
||||
)
|
||||
|
||||
def website_short(self):
|
||||
if self.website:
|
||||
return urlparse(self.website).netloc.replace("www.", "")
|
||||
|
||||
|
||||
class MagazineIssue(BaseBook):
|
||||
magazine = models.ForeignKey(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
from urllib.parse import urlparse
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
@@ -57,6 +58,10 @@ class Manufacturer(models.Model):
|
||||
},
|
||||
)
|
||||
|
||||
def website_short(self):
|
||||
if self.website:
|
||||
return urlparse(self.website).netloc.replace("www.", "")
|
||||
|
||||
def logo_thumbnail(self):
|
||||
return get_image_preview(self.logo.url)
|
||||
|
||||
|
||||
@@ -69,7 +69,9 @@
|
||||
{% if type == "catalog" %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Manufacturer</th>
|
||||
<td>{{ book.manufacturer }}</td>
|
||||
<td>
|
||||
<a href="{% url 'filtered' _filter="manufacturer" search=book.manufacturer.slug %}">{{ book.manufacturer }}{% if book.manufacturer.website %}</a> <a href="{{ book.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Scales</th>
|
||||
@@ -96,7 +98,10 @@
|
||||
{% elif type == "magazineissue" %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Magazine</th>
|
||||
<td><a href="{% url 'magazine' book.magazine.pk %}">{{ book.magazine }}</a></td>
|
||||
<td>
|
||||
<a href="{% url 'magazine' book.magazine.pk %}">{{ book.magazine }}</a>
|
||||
{% if book.magazine.website %} <a href="{{ book.magazine.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Publisher</th>
|
||||
|
||||
@@ -37,7 +37,9 @@
|
||||
{% if d.type == "catalog" %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Manufacturer</th>
|
||||
<td>{{ d.item.manufacturer }}</td>
|
||||
<td>
|
||||
<a href="{% url 'filtered' _filter="manufacturer" search=d.item.manufacturer.slug %}">{{ d.item.manufacturer }}{% if d.item.manufacturer.website %}</a> <a href="{{ d.item.manufacturer.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Scales</th>
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
<tr>
|
||||
<th colspan="2" scope="row">
|
||||
{{ d.label|capfirst }}
|
||||
|
||||
<div class="float-end">
|
||||
{% if not d.item.published %}
|
||||
<span class="badge text-bg-warning">Unpublished</span>
|
||||
@@ -57,6 +58,11 @@
|
||||
<th class="w-33" scope="row">Magazine</th>
|
||||
<td>{{ d.item.magazine }}</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Website</th>
|
||||
<td>{% if d.item.website %}<a href="{{ d.item.website }}" target="_blank">{{ d.item.website_short }}</td>{% else %}-{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Publisher</th>
|
||||
|
||||
@@ -17,12 +17,10 @@
|
||||
<td><img class="logo" src="{{ d.item.logo.url }}" alt="{{ d.item.name }} logo"></td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% if d.item.website %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Website</th>
|
||||
<td><a href="{{ d.item.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a></td>
|
||||
<td>{% if d.item.website %}<a href="{{ d.item.website }}" target="_blank">{{ d.item.website_short }}</td>{% else %}-{% endif %}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Category</th>
|
||||
<td>{{ d.item.category | title }}</td>
|
||||
|
||||
@@ -88,7 +88,7 @@
|
||||
<tbody class="table-group-divider">
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Name</th>
|
||||
<td>{{ magazine }} </td>
|
||||
<td>{{ magazine }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Publisher</th>
|
||||
@@ -97,6 +97,14 @@
|
||||
{% if magazine.publisher.website %} <a href="{{ magazine.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Website</th>
|
||||
<td>{% if magazine.website %}<a href="{{ magazine.website }}" target="_blank">{{ magazine.website_short }}</td>{% else %}-{% endif %}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="w-33" scope="row">Language</th>
|
||||
<td>{{ magazine.get_language_display }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">ISBN</th>
|
||||
<td>{{ magazine.ISBN | default:"-" }}</td>
|
||||
|
||||
@@ -73,8 +73,7 @@ class GetData(View):
|
||||
.filter(self.filter)
|
||||
)
|
||||
|
||||
def get(self, request, filter=Q(), page=1):
|
||||
self.filter = filter
|
||||
def get(self, request, page=1):
|
||||
data = []
|
||||
for item in self.get_data(request):
|
||||
data.append({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from ram.utils import git_suffix
|
||||
|
||||
__version__ = "0.18.4"
|
||||
__version__ = "0.18.5"
|
||||
__version__ += git_suffix(__file__)
|
||||
|
||||
Reference in New Issue
Block a user