-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Objects API client integration
- Loading branch information
Showing
7 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,14 @@ | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from cms.plugin_base import CMSPluginBase | ||
from cms.plugin_pool import plugin_pool | ||
|
||
from .models import ObjectsList | ||
|
||
|
||
@plugin_pool.register_plugin | ||
class ObjectsListPlugin(CMSPluginBase): | ||
model = ObjectsList | ||
name = _("Object List Plugin") | ||
render_template = "cms/objects/objects_list.html" | ||
cache = False |
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,46 @@ | ||
# Generated by Django 3.2.20 on 2023-09-17 20:14 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
import objectsapiclient.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
("cms", "0022_auto_20180620_1551"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="ObjectsList", | ||
fields=[ | ||
( | ||
"cmsplugin_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
related_name="objects_objectslist", | ||
serialize=False, | ||
to="cms.cmsplugin", | ||
), | ||
), | ||
("title", models.CharField(max_length=250, verbose_name="Title")), | ||
( | ||
"object_type", | ||
objectsapiclient.models.ObjectTypeField( | ||
db_index=False, max_length=100 | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
bases=("cms.cmsplugin",), | ||
), | ||
] |
Empty file.
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,20 @@ | ||
import os | ||
|
||
from django.db import models | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
from cms.models import CMSPlugin | ||
from objectsapiclient.models import Configuration, ObjectTypeField | ||
|
||
|
||
class ObjectsList(CMSPlugin): | ||
title = models.CharField(_("Title"), max_length=250) | ||
object_type = ObjectTypeField() # Stores the UUID of the selected object_type | ||
|
||
def get_objects(self): | ||
return Configuration.get_solo().client.get_objects( | ||
object_type_uuid=self.object_type | ||
) | ||
|
||
def __str__(self): | ||
return self.title |
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,17 @@ | ||
{% load i18n sekizai_tags %} | ||
|
||
{% load i18n button_tags card_tags utils icon_tags %} | ||
<h2 class="h2"> | ||
{{ instance.title }} | ||
</h2> | ||
<div class="plans-cards card-container card-container--columns-4"> | ||
{% for object in instance.get_objects %} | ||
{% render_card image_object_fit="cover" %} | ||
<div class="card__content"> | ||
<h3 class="h3 object-list">{{ object.record.index }}</h3> | ||
{{ object.uuid }} | ||
</div> | ||
{% endrender_card %} | ||
{% endfor %} | ||
</div> | ||
|