joshuakarjala / django-hunger Goto Github PK
View Code? Open in Web Editor NEWDjango app for managing beta signups and invitations
License: Other
Django app for managing beta signups and invitations
License: Other
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.
When i use pip install, i got this :
Downloading/unpacking django-hunger
Downloading django-hunger-1.0.8.macosx-10.4-x86_64.tar.gz
Running setup.py egg_info for package django-hunger
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: 'PATH/build/django-hunger/setup.py'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 14, in
IOError: [Errno 2] No such file or directory: 'PATH/build/django-hunger/setup.py'
Command python setup.py egg_info failed with error code 1 in 'ATH/build/django-hunger
Storing complete log in PATH/.pip/pip.log
Hi,
Great package, and I'd like to use it for our startup.
I'm trying to go over your source code, and looking at the example templates folder, I don't really understand the code structure.
You have some files that end with the .email extension, but by searching around your source code, no function is making use of those.
It seems that it is the most elegant design to make use of those templates though.
Could you suggest any best practice use of those?
Thanks a lot.
Using the instructions currently there, my app now redirects to a nonexistent '/beta/?next=/' that throws up a 404. If there are additional steps required or other things needed to get going, shouldn't they be documented?
Out of the box when sending an invite a noreversematch error is raised.
I added this to my apps ulrs. Maybe it will be helpful for someone else.
url(r'^verify/(\w+)/$', 'hunger.views.verify_invite', name='beta_verify_invite'),
Also, the urls file installed with pip, is not the same as the one in git/master.
Cheers...
https://pypi.python.org/pypi/django-hunger still has version 1.0.10, could you put version 2.0.0a (perhaps even v2.0 if you feel like it) up there ?
RIght now the middleware hardcodes a list of modules to whitelist.
Personally I think you should be moving this outside the middleware class to some getattr setup, thus allowing project integrators to at least do something about the InviteView being available to non beta users.
https://github.com/joshuakarjala/django-hunger/blob/master/hunger/middleware.py#L55-L59
I'm integrating this into yet another project and I'm using django-allauth, which allows me to take your new approach to "Get users signed up and authenticated and invite them deeper into the site later."
The problem is that you can find yourself in the situation where :
/beta/invite
This is because the invite form is whitelisted, the middleware never redirects non beta users away from it.
The expression
getattr(settings, name, None) or DEFAULT_SETTINGS[name]
will always default to DEFAULT_SETTINGS[name] if the getattr part returns False. This means that settings like HUNGER_ENABLE, will be overridden with DEFAULT_SETTINGS['HUNGER_ENABLE'] whenever the user sets it to False. So that this value will effectively always be True.
I've fixed this issue in pull request #54 which contains a test.
Firstly, thanks for updating the documentation.
In the doc, it says:
For a newbie django user like me, this is very confusing. How does one actually accomplish this?
Looking at the view code, one needs to add an entry to urls.py that takes in the request from the invite email with the invite code, parse out the activation code, and point it towards the verify_invite function. Is this correct?
This might be trivial for experienced developers, but could trip up any new developers trying to pick up django.
I was thinking of adding optional integration with https://github.com/bradwhittington/django-templated-email via conditional imports. This solves a problem when I first added the default email sending functionality where I couldn't easily customize the subject line within the template. With this integration, then users will almost never need to write a custom function and mainly just use customized email templates.
UPDATE: Fixed in 2a09aca
When an invitation is created with InviteView, the invitation is never emailed out. It gets marked as sent in the admin interface, so the only way to get it to send is to use the Resend invite command.
Something like this is needed for it to send from the view:
instance = form.save(commit=False)
instance.save(send_email=True, request=self.request)
I've added this to a view in another app for the time being.
I wanted to make sure I'm understanding the use of this view correctly before I submit a pull request. This is something for users to invite their friends, and it should send email without admin intervention, correct?
Anybody can change their cookies via an easy to use browser extension. I suggest using the django sessions framework to save these settings instead of setting a cookie.
I think there is a problem in the middleware that checks if the user is authenticated and if he does not it redirects to login url.
an invited user who wasn't registered before will not be redirected to the verified url, he will be redirected to the login url instead.
then, he will have to sign up and the verified url is bypassed.
When user is logged in and he enters public available registration code, the cookie is set and user is forced to re-login, but in my opinion code should be used immediately without logging out.
Maybe I'm missing something here, but I have a view for the root URL ("/") that shows one set of content if the user is authenticated (a list of objects) and other content if the user is not authenticated (that is, the login page). A user who is not authenticated, should see the login page. Once they are authenticated, django-hunger should show them the list of objects if they're in the beta and redirect them to /hunger/not-in-beta if they're not.
I can't figure out how to make this work though since adding the view to HUNGER_ALWAYS_ALLOW_VIEWS
means an authenticated user will see the list of objects but if I don't add it, users can't see the login page. Is there an easy solution I'm missing? Is there any way to have one URL map to two different views? If not, is this a known problem? Is it (or can it be) on the wishlist?
Thanks! This is cool. I'd love to get it working for me.
I'm running Django 1.4.8 and the bundled six version (1.2.0) does not contain the PY2 attribute.
It has PY3 and else for PY2.
Could you please fix this issue for older Django versions?
Just a small annoyance.
hunger/urls.py:from django.conf.urls.defaults
should be:
hunger/urls.py:from django.conf.urls
Adding more than one private invitation causes InviteView to throw an error.
valid_code = InvitationCode.objects.get(owner=self.request.user,
num_invites__gt=0)
Unless we are tracking the number of invites left elsewhere and creating codes only when needed, I can put in a pull request to fix this tomorrow. Maybe a template for out of invitations is in order.
I can't seem to stop coming up with issues, but I hope this one too will be helpful down the line.
I have been trying to implement the standard form validation in hunger if the form is submitted via an ajax request, but I get an arcane error as such:
AttributeError at /
'bool' object has no attribute 'get'
The traceback is quite long, but it seems to germinate from here:
C:\Python27\lib\site-packages\django\forms\forms.py in _clean_fields
del self.cleaned_data
def _clean_fields(self):
for name, field in self.fields.items():
# value_from_datadict() gets the data from the data dictionaries.
# Each widget type knows how to retrieve its own data, because some
# widgets split data over several HTML fields.
value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))
...
try:
if isinstance(field, FileField):
initial = self.initial.get(name, field.initial)
value = field.clean(value, initial)
else:
value = field.clean(value)
Any insights into this?
i'm trying to integrate django-hunger with django-registration (register and activate by mail) but i'm stuck in a 302 loop after posting to /accounts/register. (BETA_SIGNUP_URL = '/accounts/register/') i dont know what to state in: BETA_SIGNUP_CONFIRMATION_VIEW since registration doesnt have a view for this, or at least i have no idea how to.
thanks
EDIT: i changed the title for issue
It is not clear to me how one determines the number of remaining invites a user has. The method remaining_invites subtracts invited_users.count() from max_invites, so that only accepted invites will be taken into account. What if you want to limit a users invitations whether they are accepted or not?
A better way would be to subtract invitation_set.count() from max_invites, so that all invites, whether accepted or not counts towards a user's total invites sent.
Moreover, one would think that num_invites is always up to date, but it is only updated in the middleware, not upon saving an InvitationCode.
What am I missing?
Hi,
Does this app generate an email with an activation token once a user submits an email in the invite form? If you have any working examples of how this works, that would be great.
How about a new release? I've been using the latest commit for a while now without any issues. It would be nice to change my requirements.txt file from a git entry to a pypi entry.
I can't speak for everyone else, but I personally feel there is a valid use case for pre and post registration beta signup work flow.
Furthermore :
I'll be experimenting with these concepts in my own repo under https://github.com/airtonix/django-hunger/tree/develop
Hey,
in https://github.com/joshuakarjala/django-hunger/blob/master/hunger/views.py#L16 the InviteForm (the one where users invite their friends) redirects the user to 'hunger-verified', that is (quoting quickstart.rst here) "the page a user sees after successfully joining and verifying in-beta status" which seems to be wrong.
Wouldn't a new page (let's call it 'hunger-invite-complete'
) where the user sees "Thank you, we invited your friend by sending an email to {{ invited_email }}
" make more sense ?
so long,
Commit b31b881 forces verify_invite to require that the user be logged in. This is bad for user experience. Say a completely new user gets an invite per email. He clicks the link and is then immediately required to login. He probably hasn't even registered yet! This should be left to the verified view template to tell the user that it is time to register or login if he already has an account.
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/Library/Python/2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
Is there error I am getting. I am trying to run the git repo not install using pip. What am I doing wrong here? Still pretty new to this.
Upgrading to 1.7 broke the hunger installation with the following errors:
File "manage.py", line 10, in
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-packages/django/core/management/init.py", line 385, in execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/init.py", line 354, in execute
django.setup()
File "/Library/Python/2.7/site-packages/django/init.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 197, in import_models
self.models_module = import_module(models_module_name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/init.py", line 37, in import_module
import(name)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django_hunger-2.1.0-py2.7.egg/hunger/models.py", line 12, in
User = get_user_model()
File "/Library/Python/2.7/site-packages/django/contrib/auth/init.py", line 136, in get_user_model
return django_apps.get_model(settings.AUTH_USER_MODEL)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 199, in get_model
self.check_models_ready()
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 131, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
Laurens-MacBook-Pro-3:webserver-1.6.5 Lauren$
I think it would be nice to group users. Close friends, acquaintances, some company you work with, etc. So you give the whole group more invites with one action. If people like the idea I might be able to try and implement it and do a pull request. If I can figure it out of course. It would be useful for the app I am making.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.