Skip to content

Fix page type links when its label isn't set (#7) and remove the hardcoded German text - #8

Open
viktor-yunenko wants to merge 3 commits into
dreipol:masterfrom
what-digital:master
Open

Fix page type links when its label isn't set (#7) and remove the hardcoded German text#8
viktor-yunenko wants to merge 3 commits into
dreipol:masterfrom
what-digital:master

Conversation

@viktor-yunenko

Copy link
Copy Markdown

This is hardly code quality that I would push to production in normal circumstances, but it works.

As I mention in #7 in the future I imagine migrating away from LinkType's and removing this code.

@viktor-yunenko viktor-yunenko changed the title Fix page type links when its label isn't set (#7) Fix page type links when its label isn't set (#7) and remove the hardcoded German text Jul 5, 2020
@sidneywidmer

Copy link
Copy Markdown
Contributor

Hey @victor-yunenko 👋

Thanks for your propsed fix and your patience!

The template changes look great and the bugfix in the ModelLinkType is also nearly perfekt. I don't get why we need to check for pk in the changed real_value methods in the ModelLinkType and the PageLinkType?

if isinstance(self.link.data('value').get('model'), int):
    return self.model.objects.filter(pk=self.link.data('value').get('model')).first()
else:
    return self.model.objects.filter(pk=self.link.data('value').get('model').pk).first()

Wouldn't the following line be sufficient?

return self.model.objects.filter(pk=self.link.data('value').get('model')).first()

link.data('value') is supposed to hold all fields that the form contains (in the example of the ModelTypeForm the only field is model). Those fields are reflected in the value json, in our case {model: xyz }

The real_value is ment to be overwritten for everything special.

I updated the branch fix/fix/real_value with how I think this should look like, what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants