richie 2.32.0__py2.py3-none-any.whl → 2.32.1.dev1__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of richie might be problematic. Click here for more details.

@@ -151,6 +151,12 @@ $r-theme: (
151
151
  primary-color: r-color('denim'),
152
152
  secondary-color: r-color('white'),
153
153
  ),
154
+ slider-plugin: (
155
+ arrows-color: r-color('white'),
156
+ arrows-hover-color: r-color('firebrick6'),
157
+ index-color: r-color('charcoal'),
158
+ index-hover-color: r-color('black'),
159
+ ),
154
160
  blogpost-glimpse: (
155
161
  card-background: r-color('white'),
156
162
  title-color: r-color('black'),
@@ -60,6 +60,7 @@
60
60
  @import './templates/courses/plugins/category_plugin';
61
61
  @import './templates/courses/plugins/licence_plugin';
62
62
  @import './templates/richie/simpletext/simpletext';
63
+ @import './templates/richie/slider/slider';
63
64
  @import './templates/richie/section/section';
64
65
  @import './templates/richie/large_banner/large_banner';
65
66
  @import './templates/richie/large_banner/compacted_banner';
@@ -0,0 +1,142 @@
1
+ $r-slider-title-fontsize: $h1-font-size !default;
2
+ $r-slider-title-fontweight: $font-weight-bold !default;
3
+ $r-slider-title-fontfamily: $headings-font-family !default;
4
+ $r-slider-content-fontsize: $h4-font-size !default;
5
+ $r-slider-content-line-height: 1.1 !default;
6
+
7
+ .slider {
8
+ position: relative;
9
+ width: 100%;
10
+ // Reserved space for slide indexes
11
+ padding-bottom: 1.75rem;
12
+
13
+ &__items {
14
+ display: flex;
15
+ overflow-x: hidden;
16
+ }
17
+
18
+ &__tools {
19
+ @include make-container-max-widths();
20
+ margin: 0 auto;
21
+ padding: 0;
22
+ display: flex;
23
+ justify-content: center;
24
+ align-content: center;
25
+ }
26
+
27
+ &__next,
28
+ &__previous {
29
+ position: absolute;
30
+ top: 25%;
31
+ left: 0;
32
+ right: 0;
33
+ background: none;
34
+ border: 0;
35
+
36
+ svg {
37
+ width: 5rem;
38
+ height: 5rem;
39
+ color: r-theme-val(slider-plugin, arrows-color);
40
+ }
41
+
42
+ &:hover {
43
+ svg {
44
+ color: r-theme-val(slider-plugin, arrows-hover-color);
45
+ }
46
+ }
47
+ }
48
+
49
+ &__next {
50
+ left: auto;
51
+ right: 0;
52
+ }
53
+
54
+ &__previous {
55
+ left: 0;
56
+ right: auto;
57
+ }
58
+
59
+ &__indexes {
60
+ @include make-container-max-widths();
61
+ margin: 0 auto;
62
+ width: 100%;
63
+ padding: 0.5rem;
64
+ position: absolute;
65
+ bottom: 0;
66
+ display: flex;
67
+ justify-content: flex-end;
68
+ align-items: center;
69
+ }
70
+
71
+ &__index {
72
+ @include sv-flex(1, 0, 1.9rem);
73
+ padding: 0;
74
+ height: 1rem;
75
+ background: transparent;
76
+ border: 0;
77
+
78
+ &::before {
79
+ content: '';
80
+ display: block;
81
+ height: 0.2rem;
82
+ background: r-theme-val(slider-plugin, index-color);
83
+ border: 0;
84
+ }
85
+
86
+ &--active {
87
+ pointer-events: none;
88
+
89
+ &::before {
90
+ height: 0.5rem;
91
+ }
92
+ }
93
+
94
+ &:hover {
95
+ &::before {
96
+ background: r-theme-val(slider-plugin, index-hover-color);
97
+ }
98
+ }
99
+ }
100
+
101
+ &__index + &__index {
102
+ margin-left: 0.3rem;
103
+ }
104
+ }
105
+
106
+ .slider-item {
107
+ @include sv-flex(1, 0, 100%);
108
+ display: block;
109
+ color: inherit;
110
+ text-decoration: none;
111
+
112
+ // Disable any hover event on content since it can be in a link
113
+ &:hover,
114
+ *:hover {
115
+ color: inherit !important;
116
+ text-decoration: none !important;
117
+ }
118
+
119
+ &__image {
120
+ display: block;
121
+ margin: 0 0 1rem 0;
122
+ width: 100%;
123
+ }
124
+
125
+ &__container {
126
+ @include make-container-max-widths();
127
+ position: relative;
128
+ margin: 0 auto;
129
+ }
130
+
131
+ &__title {
132
+ @include font-size($r-slider-title-fontsize);
133
+ font-family: $r-slider-title-fontfamily;
134
+ font-weight: $r-slider-title-fontweight;
135
+ margin: 0 0 0.5rem 0;
136
+ }
137
+
138
+ &__content {
139
+ @include font-size($r-slider-content-fontsize);
140
+ line-height: $r-slider-content-line-height;
141
+ }
142
+ }
@@ -182,3 +182,6 @@ $r-section-grid-gutters: (
182
182
  'sm': 0.5rem,
183
183
  'xl': 1rem,
184
184
  );
185
+
186
+ // Slider plugin adjustments
187
+ $r-slider-title-fontweight: $font-weight-extrabold;
@@ -114,7 +114,7 @@ CMS_PLACEHOLDER_CONF = {
114
114
  # Homepage
115
115
  "richie/homepage.html maincontent": {
116
116
  "name": _("Main content"),
117
- "plugins": ["LargeBannerPlugin", "SectionPlugin"],
117
+ "plugins": ["LargeBannerPlugin", "SectionPlugin", "SliderPlugin"],
118
118
  "child_classes": {
119
119
  "SectionPlugin": [
120
120
  "BlogPostPlugin",
File without changes
@@ -0,0 +1,85 @@
1
+ """
2
+ Slider CMS plugins
3
+ """
4
+
5
+ from django.utils.translation import gettext_lazy as _
6
+
7
+ from cms.plugin_base import CMSPluginBase
8
+ from cms.plugin_pool import plugin_pool
9
+
10
+ from richie.apps.core.defaults import PLUGINS_GROUP
11
+
12
+ from .forms import SlideItemForm, SliderForm
13
+ from .models import SlideItem, Slider
14
+
15
+
16
+ @plugin_pool.register_plugin
17
+ class SliderPlugin(CMSPluginBase):
18
+ """
19
+ CMSPlugin to hold Slide plugin items.
20
+ """
21
+
22
+ cache = True
23
+ module = PLUGINS_GROUP
24
+ name = _("Slider")
25
+ model = Slider
26
+ form = SliderForm
27
+ render_template = "richie/slider/slider.html"
28
+ allow_children = True
29
+ child_classes = ["SlideItemPlugin"]
30
+ fieldsets = ((None, {"fields": ["title"]}),)
31
+
32
+ def render(self, context, instance, placeholder):
33
+ context.update(
34
+ {
35
+ "instance": instance,
36
+ "placeholder": placeholder,
37
+ }
38
+ )
39
+ return context
40
+
41
+
42
+ @plugin_pool.register_plugin
43
+ class SlideItemPlugin(CMSPluginBase):
44
+ """
45
+ CMSPlugin for slide item content.
46
+ """
47
+
48
+ cache = True
49
+ module = PLUGINS_GROUP
50
+ name = _("Slide item")
51
+ model = SlideItem
52
+ form = SlideItemForm
53
+ render_template = "richie/slider/slide-item.html"
54
+ require_parent = True
55
+ parent_classes = ["SliderPlugin"]
56
+ fieldsets = [
57
+ (
58
+ None,
59
+ {
60
+ "fields": (
61
+ "title",
62
+ "image",
63
+ "content",
64
+ ),
65
+ },
66
+ ),
67
+ (
68
+ _("Link"),
69
+ {
70
+ "fields": (
71
+ "link_url",
72
+ "link_open_blank",
73
+ ),
74
+ },
75
+ ),
76
+ ]
77
+
78
+ def render(self, context, instance, placeholder):
79
+ context.update(
80
+ {
81
+ "instance": instance,
82
+ "placeholder": placeholder,
83
+ }
84
+ )
85
+ return context
@@ -0,0 +1,33 @@
1
+ """
2
+ Slider CMS plugin factories
3
+ """
4
+
5
+ import factory
6
+
7
+ from .models import SlideItem, Slider
8
+
9
+
10
+ class SliderFactory(factory.django.DjangoModelFactory):
11
+ """
12
+ Factory to create instance of a Slider.
13
+ """
14
+
15
+ title = factory.Faker("text", max_nb_chars=20)
16
+
17
+ class Meta:
18
+ model = Slider
19
+
20
+
21
+ class SlideItemFactory(factory.django.DjangoModelFactory):
22
+ """
23
+ Factory to create instance of a SlideItem.
24
+ """
25
+
26
+ title = factory.Faker("text", max_nb_chars=20)
27
+ content = factory.Faker("text", max_nb_chars=42)
28
+ image = factory.SubFactory("richie.apps.core.factories.FilerImageFactory")
29
+ link_url = factory.Faker("url")
30
+ link_open_blank = factory.Faker("pybool")
31
+
32
+ class Meta:
33
+ model = SlideItem
@@ -0,0 +1,40 @@
1
+ """
2
+ Slider plugin forms
3
+ """
4
+
5
+ from django import forms
6
+
7
+ from djangocms_text_ckeditor.widgets import TextEditorWidget
8
+
9
+ from .models import SlideItem, Slider
10
+
11
+
12
+ class SliderForm(forms.ModelForm):
13
+ """
14
+ Slider form used to fill its content from frontend admin.
15
+ """
16
+
17
+ class Meta:
18
+ model = Slider
19
+ fields = [
20
+ "title",
21
+ ]
22
+
23
+
24
+ class SlideItemForm(forms.ModelForm):
25
+ """
26
+ SlideItem form used to fill its content from frontend admin.
27
+ """
28
+
29
+ class Meta:
30
+ model = SlideItem
31
+ fields = [
32
+ "title",
33
+ "image",
34
+ "content",
35
+ "link_url",
36
+ "link_open_blank",
37
+ ]
38
+ widgets = {
39
+ "content": TextEditorWidget,
40
+ }
@@ -0,0 +1,102 @@
1
+ # Generated by Django 4.2.16 on 2024-11-22 00:16
2
+
3
+ import django.db.models.deletion
4
+ from django.conf import settings
5
+ from django.db import migrations, models
6
+
7
+ import filer.fields.image
8
+
9
+
10
+ class Migration(migrations.Migration):
11
+
12
+ initial = True
13
+
14
+ dependencies = [
15
+ ("cms", "0022_auto_20180620_1551"),
16
+ migrations.swappable_dependency(settings.FILER_IMAGE_MODEL),
17
+ ]
18
+
19
+ operations = [
20
+ migrations.CreateModel(
21
+ name="Slider",
22
+ fields=[
23
+ (
24
+ "cmsplugin_ptr",
25
+ models.OneToOneField(
26
+ auto_created=True,
27
+ on_delete=django.db.models.deletion.CASCADE,
28
+ parent_link=True,
29
+ primary_key=True,
30
+ related_name="%(app_label)s_%(class)s",
31
+ serialize=False,
32
+ to="cms.cmsplugin",
33
+ ),
34
+ ),
35
+ ("title", models.CharField(max_length=255, verbose_name="title")),
36
+ ],
37
+ options={
38
+ "verbose_name": "Slider",
39
+ "verbose_name_plural": "Sliders",
40
+ },
41
+ bases=("cms.cmsplugin",),
42
+ ),
43
+ migrations.CreateModel(
44
+ name="SlideItem",
45
+ fields=[
46
+ (
47
+ "cmsplugin_ptr",
48
+ models.OneToOneField(
49
+ auto_created=True,
50
+ on_delete=django.db.models.deletion.CASCADE,
51
+ parent_link=True,
52
+ primary_key=True,
53
+ related_name="%(app_label)s_%(class)s",
54
+ serialize=False,
55
+ to="cms.cmsplugin",
56
+ ),
57
+ ),
58
+ (
59
+ "title",
60
+ models.CharField(default="", max_length=150, verbose_name="title"),
61
+ ),
62
+ (
63
+ "content",
64
+ models.TextField(blank=True, default="", verbose_name="content"),
65
+ ),
66
+ (
67
+ "link_url",
68
+ models.URLField(
69
+ blank=True,
70
+ help_text="Make the slide as a link with an URL.",
71
+ max_length=255,
72
+ null=True,
73
+ verbose_name="link URL",
74
+ ),
75
+ ),
76
+ (
77
+ "link_open_blank",
78
+ models.BooleanField(
79
+ default=False,
80
+ help_text="If checked the link will be open in a new window",
81
+ verbose_name="open new window",
82
+ ),
83
+ ),
84
+ (
85
+ "image",
86
+ filer.fields.image.FilerImageField(
87
+ default=None,
88
+ null=True,
89
+ on_delete=django.db.models.deletion.SET_NULL,
90
+ related_name="slide_image",
91
+ to=settings.FILER_IMAGE_MODEL,
92
+ verbose_name="image",
93
+ ),
94
+ ),
95
+ ],
96
+ options={
97
+ "verbose_name": "Slide item",
98
+ "verbose_name_plural": "Slide items",
99
+ },
100
+ bases=("cms.cmsplugin",),
101
+ ),
102
+ ]
File without changes
@@ -0,0 +1,111 @@
1
+ """
2
+ Slider plugin models
3
+ """
4
+
5
+ from django.db import models
6
+ from django.utils.translation import gettext_lazy as _
7
+
8
+ from cms.models.pluginmodel import CMSPlugin
9
+ from filer.fields.image import FilerImageField
10
+
11
+
12
+ class Slider(CMSPlugin):
13
+ """
14
+ Slide container plugin for Slide item plugins.
15
+ """
16
+
17
+ title = models.CharField(_("title"), max_length=255)
18
+
19
+ class Meta:
20
+ verbose_name = _("Slider")
21
+ verbose_name_plural = _("Sliders")
22
+
23
+ def __str__(self):
24
+ return self.title
25
+
26
+ @property
27
+ def front_identifier(self):
28
+ """
29
+ Return standardized identifier for the slider container.
30
+ """
31
+ return f"slider-{self.id}"
32
+
33
+ @property
34
+ def payload_identifier(self):
35
+ """
36
+ Return standardized identifier for the slider payload.
37
+ """
38
+ return f"{self.front_identifier}-data"
39
+
40
+ def get_slider_payload(self):
41
+ """
42
+ Serializer a slider object and its slide items to Python object.
43
+
44
+ Arguments:
45
+ instance (richie.plugins.slider.models.SlideItem): Instance of a Slider
46
+ object.
47
+
48
+ Returns:
49
+ dict: Dictionnary of slider data.
50
+ """
51
+
52
+ slides = self.child_plugin_instances or []
53
+
54
+ return {
55
+ "pk": self.id,
56
+ "title": self.title,
57
+ "slides": [
58
+ {
59
+ "pk": plugin.id,
60
+ "title": plugin.title,
61
+ "image": plugin.image.url,
62
+ "content": plugin.content,
63
+ "link_url": plugin.link_url,
64
+ "link_open_blank": plugin.link_open_blank,
65
+ }
66
+ for plugin in slides
67
+ ],
68
+ }
69
+
70
+
71
+ class SlideItem(CMSPlugin):
72
+ """
73
+ Slide item plugin to include in a Slider plugin.
74
+ """
75
+
76
+ title = models.CharField(
77
+ _("title"),
78
+ max_length=150,
79
+ default="",
80
+ )
81
+ image = FilerImageField(
82
+ related_name="slide_image",
83
+ verbose_name=_("image"),
84
+ on_delete=models.SET_NULL,
85
+ null=True,
86
+ default=None,
87
+ )
88
+ content = models.TextField(
89
+ _("content"),
90
+ blank=True,
91
+ default="",
92
+ )
93
+ link_url = models.URLField(
94
+ verbose_name=_("link URL"),
95
+ blank=True,
96
+ null=True,
97
+ max_length=255,
98
+ help_text=_("Make the slide as a link with an URL."),
99
+ )
100
+ link_open_blank = models.BooleanField(
101
+ _("open new window"),
102
+ default=False,
103
+ help_text=_("If checked the link will be open in a new window"),
104
+ )
105
+
106
+ class Meta:
107
+ verbose_name = _("Slide item")
108
+ verbose_name_plural = _("Slide items")
109
+
110
+ def __str__(self):
111
+ return self.title
@@ -0,0 +1,4 @@
1
+ {% load cms_tags i18n %}{% spaceless %}
2
+ <div id="{{ instance.front_identifier }}" class="slider" data-props-source="#{{ instance.payload_identifier }}"></div>
3
+ {{ instance.get_slider_payload|json_script:instance.payload_identifier }}
4
+ {% endspaceless %}