mirror of
https://github.com/daniviga/django-ram.git
synced 2026-02-04 10:00:40 +01:00
Compare commits
9 Commits
c539255bf9
...
magazine
| Author | SHA1 | Date | |
|---|---|---|---|
|
49da8f58fe
|
|||
|
0688725326
|
|||
|
cd1369e9c9
|
|||
|
02ed907f12
|
|||
|
8a3101364e
|
|||
|
7f456890dd
|
|||
|
5e6366e10c
|
|||
|
361a05e3a8
|
|||
|
1d683b8519
|
@@ -475,7 +475,6 @@ class MagazineAdmin(SortableAdminBase, admin.ModelAdmin):
|
|||||||
"fields": (
|
"fields": (
|
||||||
"published",
|
"published",
|
||||||
"name",
|
"name",
|
||||||
"website",
|
|
||||||
"publisher",
|
"publisher",
|
||||||
"ISBN",
|
"ISBN",
|
||||||
"language",
|
"language",
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
# 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,6 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from urllib.parse import urlparse
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@@ -170,7 +169,6 @@ class Catalog(BaseBook):
|
|||||||
class Magazine(BaseModel):
|
class Magazine(BaseModel):
|
||||||
name = models.CharField(max_length=200)
|
name = models.CharField(max_length=200)
|
||||||
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
|
publisher = models.ForeignKey(Publisher, on_delete=models.CASCADE)
|
||||||
website = models.URLField(blank=True)
|
|
||||||
ISBN = models.CharField(max_length=17, blank=True) # 13 + dashes
|
ISBN = models.CharField(max_length=17, blank=True) # 13 + dashes
|
||||||
image = models.ImageField(
|
image = models.ImageField(
|
||||||
blank=True,
|
blank=True,
|
||||||
@@ -207,10 +205,6 @@ class Magazine(BaseModel):
|
|||||||
kwargs={"uuid": self.uuid}
|
kwargs={"uuid": self.uuid}
|
||||||
)
|
)
|
||||||
|
|
||||||
def website_short(self):
|
|
||||||
if self.website:
|
|
||||||
return urlparse(self.website).netloc.replace("www.", "")
|
|
||||||
|
|
||||||
|
|
||||||
class MagazineIssue(BaseBook):
|
class MagazineIssue(BaseBook):
|
||||||
magazine = models.ForeignKey(
|
magazine = models.ForeignKey(
|
||||||
|
|||||||
@@ -49,5 +49,3 @@ class CatalogSerializer(serializers.ModelSerializer):
|
|||||||
"price",
|
"price",
|
||||||
)
|
)
|
||||||
read_only_fields = ("creation_time", "updated_time")
|
read_only_fields = ("creation_time", "updated_time")
|
||||||
|
|
||||||
# FIXME: add Magazine and MagazineIssue serializers
|
|
||||||
|
|||||||
@@ -38,5 +38,3 @@ class CatalogGet(RetrieveAPIView):
|
|||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
return Book.objects.get_published(self.request.user)
|
return Book.objects.get_published(self.request.user)
|
||||||
|
|
||||||
# FIXME: add Magazine and MagazineIssue views
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import os
|
import os
|
||||||
from urllib.parse import urlparse
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
@@ -58,10 +57,6 @@ class Manufacturer(models.Model):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
def website_short(self):
|
|
||||||
if self.website:
|
|
||||||
return urlparse(self.website).netloc.replace("www.", "")
|
|
||||||
|
|
||||||
def logo_thumbnail(self):
|
def logo_thumbnail(self):
|
||||||
return get_image_preview(self.logo.url)
|
return get_image_preview(self.logo.url)
|
||||||
|
|
||||||
|
|||||||
@@ -61,7 +61,8 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">
|
<th colspan="2" scope="row">
|
||||||
{{ label|capfirst }}
|
{% if type == "catalog" %}Catalog
|
||||||
|
{% elif type == "book" %}Book{% endif %}
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -69,9 +70,7 @@
|
|||||||
{% if type == "catalog" %}
|
{% if type == "catalog" %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Manufacturer</th>
|
<th class="w-33" scope="row">Manufacturer</th>
|
||||||
<td>
|
<td>{{ book.manufacturer }}</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>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Scales</th>
|
<th class="w-33" scope="row">Scales</th>
|
||||||
@@ -98,10 +97,7 @@
|
|||||||
{% elif type == "magazineissue" %}
|
{% elif type == "magazineissue" %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Magazine</th>
|
<th class="w-33" scope="row">Magazine</th>
|
||||||
<td>
|
<td><a href="{% url 'magazine' book.magazine.pk %}">{{ book.magazine }}</a></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>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Publisher</th>
|
<th class="w-33" scope="row">Publisher</th>
|
||||||
@@ -116,7 +112,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Date</th>
|
<th class="w-33" scope="row">Date</th>
|
||||||
<td>{{ book.publication_year|default:"-" }} / {{ book.get_publication_month_display|default:"-" }}</td>
|
<td>{{ book.publication_year|default:"-" }} / {{ book.publication_month|default:"-" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">
|
<th colspan="2" scope="row">
|
||||||
{{ d.label|capfirst }}
|
{{ d.type | capfirst }}
|
||||||
<div class="float-end">
|
<div class="float-end">
|
||||||
{% if not d.item.published %}
|
{% if not d.item.published %}
|
||||||
<span class="badge text-bg-warning">Unpublished</span>
|
<span class="badge text-bg-warning">Unpublished</span>
|
||||||
@@ -37,9 +37,7 @@
|
|||||||
{% if d.type == "catalog" %}
|
{% if d.type == "catalog" %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Manufacturer</th>
|
<th class="w-33" scope="row">Manufacturer</th>
|
||||||
<td>
|
<td>{{ d.item.manufacturer }}</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>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Scales</th>
|
<th class="w-33" scope="row">Scales</th>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
{% load dynamic_url %}
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
{% if d.type == "magazine" %}
|
{% if d.type == "magazine" %}
|
||||||
@@ -42,8 +41,7 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2" scope="row">
|
<th colspan="2" scope="row">
|
||||||
{{ d.label|capfirst }}
|
{{ d.type | capfirst }}
|
||||||
|
|
||||||
<div class="float-end">
|
<div class="float-end">
|
||||||
{% if not d.item.published %}
|
{% if not d.item.published %}
|
||||||
<span class="badge text-bg-warning">Unpublished</span>
|
<span class="badge text-bg-warning">Unpublished</span>
|
||||||
@@ -58,11 +56,6 @@
|
|||||||
<th class="w-33" scope="row">Magazine</th>
|
<th class="w-33" scope="row">Magazine</th>
|
||||||
<td>{{ d.item.magazine }}</td>
|
<td>{{ d.item.magazine }}</td>
|
||||||
</tr>
|
</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 %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Publisher</th>
|
<th class="w-33" scope="row">Publisher</th>
|
||||||
@@ -78,7 +71,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Date</th>
|
<th class="w-33" scope="row">Date</th>
|
||||||
<td>{{ d.item.publication_year|default:"-" }} / {{ d.item.get_publication_month_display|default:"-" }}</td>
|
<td>{{ d.item.publication_year|default:"-" }} / {{ d.item.publication_month|default:"-" }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Pages</th>
|
<th class="w-33" scope="row">Pages</th>
|
||||||
@@ -97,7 +90,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<a class="btn btn-sm btn-outline-primary" href="{{ d.item.get_absolute_url }}">Show all data</a>
|
<a class="btn btn-sm btn-outline-primary" href="{{ d.item.get_absolute_url }}">Show all data</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% dynamic_admin_url 'bookshelf' d.type d.item.pk %}">Edit</a>{% endif %}
|
{% if request.user.is_staff %}<a class="btn btn-sm btn-outline-danger" href="{% url 'admin:bookshelf_magazineissue_change' d.item.pk %}">Edit</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,10 +17,12 @@
|
|||||||
<td><img class="logo" src="{{ d.item.logo.url }}" alt="{{ d.item.name }} logo"></td>
|
<td><img class="logo" src="{{ d.item.logo.url }}" alt="{{ d.item.name }} logo"></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if d.item.website %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Website</th>
|
<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>
|
<td><a href="{{ d.item.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Category</th>
|
<th class="w-33" scope="row">Category</th>
|
||||||
<td>{{ d.item.category | title }}</td>
|
<td>{{ d.item.category | title }}</td>
|
||||||
|
|||||||
@@ -88,7 +88,7 @@
|
|||||||
<tbody class="table-group-divider">
|
<tbody class="table-group-divider">
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Name</th>
|
<th class="w-33" scope="row">Name</th>
|
||||||
<td>{{ magazine }}</td>
|
<td>{{ magazine }} </td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-33" scope="row">Publisher</th>
|
<th class="w-33" scope="row">Publisher</th>
|
||||||
@@ -97,14 +97,6 @@
|
|||||||
{% if magazine.publisher.website %} <a href="{{ magazine.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
{% if magazine.publisher.website %} <a href="{{ magazine.publisher.website }}" target="_blank"><i class="bi bi-box-arrow-up-right"></i></a>{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<th scope="row">ISBN</th>
|
<th scope="row">ISBN</th>
|
||||||
<td>{{ magazine.ISBN | default:"-" }}</td>
|
<td>{{ magazine.ISBN | default:"-" }}</td>
|
||||||
|
|||||||
@@ -73,14 +73,11 @@ class GetData(View):
|
|||||||
.filter(self.filter)
|
.filter(self.filter)
|
||||||
)
|
)
|
||||||
|
|
||||||
def get(self, request, page=1):
|
def get(self, request, filter=Q(), page=1):
|
||||||
|
self.filter = filter
|
||||||
data = []
|
data = []
|
||||||
for item in self.get_data(request):
|
for item in self.get_data(request):
|
||||||
data.append({
|
data.append({"type": self.item_type, "item": item})
|
||||||
"type": self.item_type,
|
|
||||||
"label": self.item_type.capitalize(),
|
|
||||||
"item": item
|
|
||||||
})
|
|
||||||
|
|
||||||
paginator = Paginator(data, get_items_per_page())
|
paginator = Paginator(data, get_items_per_page())
|
||||||
data = paginator.get_page(page)
|
data = paginator.get_page(page)
|
||||||
@@ -672,7 +669,6 @@ class GetMagazine(View):
|
|||||||
data = [
|
data = [
|
||||||
{
|
{
|
||||||
"type": "magazineissue",
|
"type": "magazineissue",
|
||||||
"label": "Magazine issue",
|
|
||||||
"item": i,
|
"item": i,
|
||||||
}
|
}
|
||||||
for i in magazine.issue.get_published(request.user).all()
|
for i in magazine.issue.get_published(request.user).all()
|
||||||
@@ -716,7 +712,6 @@ class GetMagazineIssue(View):
|
|||||||
"documents": documents,
|
"documents": documents,
|
||||||
"properties": properties,
|
"properties": properties,
|
||||||
"type": "magazineissue",
|
"type": "magazineissue",
|
||||||
"label": "Magazine issue",
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -747,7 +742,6 @@ class GetBookCatalog(View):
|
|||||||
"documents": documents,
|
"documents": documents,
|
||||||
"properties": properties,
|
"properties": properties,
|
||||||
"type": selector,
|
"type": selector,
|
||||||
"label": selector.capitalize(),
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from ram.utils import git_suffix
|
from ram.utils import git_suffix
|
||||||
|
|
||||||
__version__ = "0.18.5"
|
__version__ = "0.18.1"
|
||||||
__version__ += git_suffix(__file__)
|
__version__ += git_suffix(__file__)
|
||||||
|
|||||||
Reference in New Issue
Block a user