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

beta_invite email context: Use sites framework #30

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

Conversation

peritus
Copy link
Contributor

@peritus peritus commented May 13, 2013

This contains one fix and one improvement:

(1) Uses Site.objects.get_current() to build the invitation verify url when sending emails. This is done in a similar fashion to how django-registration does it.

This is needed if the admin site and the production site have different domains.

(2) I found an old reference to the named url pattern beta_invite_url (that's the only occurrence, I grepped the whole repo), which I updated.

This is done in a similar fashion to how
django-registration does it.

This is useful if the admin site and the
production site have different domains.
@peritus
Copy link
Contributor Author

peritus commented May 13, 2013

BTW, this is how hunger/invite_email.txt looks like afterwards:

Congratulations, you've been invited!

http://{{ site.domain }}{% url 'hunger-verify' code %}

@yesimon
Copy link
Collaborator

yesimon commented May 14, 2013

I would suggest using the get_current_site(request) function instead to clean it up a bit as it does the check and returns a RequestSite automatically if the sites framework is not installed.

https://docs.djangoproject.com/en/dev/ref/contrib/sites/#hooking-into-the-current-site-from-views

@peritus
Copy link
Contributor Author

peritus commented May 14, 2013

It explicitly checks for it:

24   +    if Site._meta.installed:

.. But I'd have to check documentation on why this works.

@yesimon
Copy link
Collaborator

yesimon commented Oct 24, 2013

Yes the idea is not to rely on internal private properties, like Site._meta, even though it has been stable for ages. get_current_site helps keep track if there are backwards incompatible changes in the future.

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