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

is_in_beta function #58

Open
jayfk opened this issue Sep 1, 2014 · 1 comment
Open

is_in_beta function #58

jayfk opened this issue Sep 1, 2014 · 1 comment

Comments

@jayfk
Copy link

jayfk commented Sep 1, 2014

I have the view serving my domain root in HUNGER_ALWAYS_ALLOW_VIEWS. For non-beta users I'd like to display a landing page.

I could'nt find a obvious way to do this using django-hunger, so I decided to write a simple function that checks if the user is in beta that is called in the template.

def is_in_beta(self):
    from hunger.models import Invitation
    if not self.is_authenticated():
       return False

    if self.is_staff or self.is_superuser:
        return True

    return Invitation.objects.filter(user=self, invited__isnull=False).exists()

Will this suffice? If yes, It'd nice to have the function in hunger.utils or somewhere else.

@yesimon
Copy link
Collaborator

yesimon commented Sep 5, 2014

It should probably be a bit more complicated than that. See https://github.com/joshuakarjala/django-hunger/blob/master/hunger/middleware.py#L94 for a bit of caching. However what you have should work at a basic level so I'd appreciate any pull requests.

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

No branches or pull requests

2 participants