Skip to content
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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

viktor-yunenko
Copy link

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
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