-
Notifications
You must be signed in to change notification settings - Fork 0
deleted field softpage_enabled and added field link target which has a #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: v2.8.0
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Generated by Django 2.2.12 on 2020-04-17 10:50 | ||
|
|
||
| from django.db import migrations, models | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('allink_teaser', '0006_auto_20200205_1436'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.AddField( | ||
| model_name='allinkteaserplugin', | ||
| name='link_target', | ||
| field=models.IntegerField(blank=True, choices=[(1, 'New window'), (2, 'Softpage')], null=True, verbose_name='Link Target'), | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # Generated by Django 2.2.12 on 2020-04-17 10:52 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| def set_new_default_value(apps, schema_editor): | ||
| AllinkTeaserPlugin = apps.get_model('allink_teaser', 'AllinkTeaserPlugin') | ||
| for teaser in AllinkTeaserPlugin.objects.all(): | ||
| if teaser.softpage_enabled: | ||
| teaser.link_target = 2 | ||
| teaser.save() | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('allink_teaser', '0007_allinkteaserplugin_link_target'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RunPython(set_new_default_value), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Generated by Django 2.2.12 on 2020-04-17 11:17 | ||
|
|
||
| from django.db import migrations | ||
|
|
||
|
|
||
| class Migration(migrations.Migration): | ||
|
|
||
| dependencies = [ | ||
| ('allink_teaser', '0008_auto_20200417_1052'), | ||
| ] | ||
|
|
||
| operations = [ | ||
| migrations.RemoveField( | ||
| model_name='allinkteaserplugin', | ||
| name='softpage_enabled', | ||
| ), | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,14 @@ | |
| from allink_core.core.utils import get_additional_templates | ||
| from allink_core.core.models.fields_model import AllinkTeaserFieldsModel, AllinkTeaserTranslatedFieldsModel | ||
|
|
||
| NEW_WINDOW = 1 | ||
| SOFTPAGE = 2 | ||
|
|
||
| TARGET_CHOICES = ( | ||
| (NEW_WINDOW, 'New window'), | ||
| (SOFTPAGE, 'Softpage'), | ||
| ) | ||
|
|
||
|
|
||
| class AllinkTeaserPlugin(AllinkInternalLinkFieldsModel, AllinkTeaserFieldsModel, AllinkTeaserTranslatedFieldsModel, | ||
| CMSPlugin): | ||
|
|
@@ -16,11 +24,11 @@ class AllinkTeaserPlugin(AllinkInternalLinkFieldsModel, AllinkTeaserFieldsModel, | |
| max_length=50 | ||
| ) | ||
|
|
||
| softpage_enabled = models.BooleanField( | ||
| 'Show detailed information in Softpage', | ||
| help_text='If checked, the detail view of an entry will be displayed in a "softpage".' | ||
| ' Otherwise the page will be reloaded.', | ||
| default=False | ||
| link_target = models.IntegerField( | ||
| 'Link Target', | ||
| choices=TARGET_CHOICES, | ||
| null=True, | ||
| blank=True | ||
| ) | ||
|
|
||
| cmsplugin_ptr = CMSPluginField() | ||
|
|
@@ -34,3 +42,29 @@ def get_templates(cls): | |
| for x, y in get_additional_templates('TEASER'): | ||
| templates += ((x, y),) | ||
| return templates | ||
|
|
||
| @property | ||
| def softpage_enabled(self): | ||
| return True if self.link_target == SOFTPAGE else False | ||
|
|
||
| @property | ||
| def new_window(self): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. naming |
||
| return True if self.link_target == NEW_WINDOW else False | ||
|
|
||
| @property | ||
| def link_attributes(self): | ||
| if self.link_target == NEW_WINDOW: | ||
| return 'target=_blank' | ||
| elif self.link_target == SOFTPAGE: | ||
| return 'data-icon-softpage' | ||
| else: | ||
| return None | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is "None" the correct default value to return here, when we want to open in the same window? |
||
|
|
||
| @property | ||
| def link_icon(self): | ||
| if self.link_target == NEW_WINDOW: | ||
| return 'arrow-external' | ||
| elif self.link_target == SOFTPAGE: | ||
| return 'softpage' | ||
| else: | ||
| return None | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |
| <div class="teaser__link"> | ||
| {% if instance.softpage_enabled %} | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this if/ else statement is probably obsolete, since you added the properties "link_icon" and "link_attributes" on the model, right? |
||
| {% include "partials/buttons/link.html" with link_url=teaser_link link_label=teaser_link_text link_classes="btn" link_attributes='data-trigger-softpage' icon="softpage" %} | ||
| {% elif instance.new_window %} | ||
| {% include "partials/buttons/link.html" with link_url=teaser_link link_label=teaser_link_text link_classes="btn" link_attributes='target=_blank' icon="arrow-external" %} | ||
| {% else %} | ||
| {% include "partials/buttons/link.html" with link_url=teaser_link link_label=teaser_link_text link_classes="btn" %} | ||
| {% endif %} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move "TARGET_CHOICES" to AllinkTeaserPlugin as a class attribute.