Git Product home page Git Product logo

django-invitations's Introduction

django-invitations's People

Contributors

aaronkazah avatar adiman9 avatar alexsilva avatar barseghyanartur avatar bee-keeper avatar bengolder avatar benwad avatar brylie avatar ckkz-it avatar clokep avatar curtisstpierre avatar dependabot[bot] avatar edwardbetts avatar emilepetrone avatar eugena avatar giussepi avatar hubdotcom avatar jacklinke avatar jayvdb avatar jbc22 avatar jezdez avatar joshjo avatar mdrie avatar mrcordeiro avatar null-none avatar pre-commit-ci[bot] avatar radwon avatar scratchmex avatar valberg avatar will-copperleaf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-invitations's Issues

Catching exceptions in SendInvite view

In SendInvite view, in form_valid method there's a try-except block, that catches too many exceptions.

I've spend several hours today debugging what's going on only to find out that I've forgot to configure email sending, and that this block silently threw away exception from send_invitation (since it's not form validation error it's not shown anywhere).

My proposal is to move send_invitation out from try, and let it fail.

Remove unique constraint on email

Would you consider removing the constraint on emails being unique?

I was considering submitting a PR to make it optional with a setting in app_settings, but it seems like it may be a common use-case to be able to send multiple invites - such as after an initial invite has expired.

With the current constraint, the original invitation must be deleted first. A user following a previously expired invitation would then receive an error instead of a message that the invitation had expired.

If email isn't unique we can keep track of who sent invitations and when.

Many thanks for this app - simple but effective!

use post save handler for invites instead of override create

I was reading the code and I was wondering why you implemented a create method for the invite class and not a post save callback. In my opinion save signals are the way to go (afaik create is not called when saving an instance with pk=None).

p.s. I can contribute a PR with this if you are willing to merge it ;)

Email is not sent.

Hello,

For some reason, the email is not sent. I have tried on my local machine and on Pythonanywhere, I have configured as shown on the readme.md

Thanks!

Admin invitations

I modified the admin for the invitations to be able to send the email invitations directly from the admin, would this be an addition of interest?

invite form is broken

it's subclassing allauth's AddEmailForm, it does not make any sense to me and it's also broken (the user parameter is not send at init time).

Allow multiple invites per email

I'm trying to use django-invitations for a project which involves sending invites to people to join organizations modeled after Github organizations, but this app doesn't allow that behavior right now.

Can we leave up to the user to define whether they want to send multiple invites to the same email or not? possibly using a setting.

Site set to invite only

Maybe I'm doing this wrong...

I have settings as:

INVITATIONS_INVITATION_EXPIRY = 14 INVITATIONS_INVITATION_ONLY = True INVITATIONS_GONE_ON_ACCEPT_ERROR = False INVITATIONS_SIGNUP_REDIRECT = '/u/register/' INVITATIONS_CONFIRM_INVITE_ON_GET = True INVITATIONS_ALLOW_JSON_INVITES = False INVITATIONS_LOGIN_REDIRECT = LOGIN_URL

I can invite users just fine, but I can also register directly at the signup page. Is there something I need to change to the signup view?

Translations

All strings for endusers need to be translatable.

Allow settings to influence email subject prefix

I wanted to override the email subject prefix, but the prefix cannot be adjusted using templates. It is set by the adapter's format_email_subject method. Django includes a setting to adjust the email prefix, settings.EMAIL_SUBJECT_PREFIX, but django-invitations ignores this setting.

Compare these methods in django-allauth and django-invitations:

# in allauth.account.adapter.DefaultAccountAdapter
    def format_email_subject(self, subject):
        prefix = app_settings.EMAIL_SUBJECT_PREFIX
        if prefix is None:
            site = get_current_site(self.request)
            prefix = "[{name}] ".format(name=site.name)
        return prefix + force_text(subject)


# in invitations.adapters.BaseInvitationsAdapter
    def format_email_subject(self, subject):
        site = Site.objects.get_current()
        prefix = "[{name}] ".format(name=site.name)
        return prefix + force_text(subject)

I thought this might be a basic level of configuration that others would want, so I submitted a PR: #41

validate_invitation being called twice when sending an invite?

I'm getting two messages when sending a new invite:

This e-mail address has already been invited
[email protected] has been invited

It seems that validate_invitation is being called twice.

I did some debugging, and noticed that the following line in the SendInvite view somehow causes it to be called twice:

return self.render_to_response(
            self.get_context_data(
                success_message='%s has been invited' % email))

Calling self.get_context_data alone doesn't trigger the bug. Only when passing the returned value of self.get_context_data to self.render_to_response causes it.

Changing it to:

return self.render_to_response({
    'form': form,
    'success_message': '%s has been invited' % email
})

seems to fix the bug.

EDIT: using Django 1.9.5

Django 2.0 deprecation warnings

When using invitations:

/usr/local/venv/local/lib/python2.7/site-packages/invitations/models.py:5: RemovedInDjango20Warning: Importing from django.core.urlresolvers is deprecated in favor of django.urls.
  from django.core.urlresolvers import reverse
/usr/local/venv/local/lib/python2.7/site-packages/invitations/base_invitation.py:15: RemovedInDjango20Warning: on_delete will be a required arg for ForeignKey in Django 2.0. Set it to models.CASCADE on models and in existing migrations if you want to maintain the current default behavior. See https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.ForeignKey.on_delete
  settings.AUTH_USER_MODEL, null=True, blank=True)

Possibility to subclass InvitationsAdapter for Allauth use?

I want to subclass invitations.models.InvitationsAdapter to change Allauth's default ajax_response() method. However, I noticed that the InvitationsAdapter class only exists if settings.ACCOUNT_ADAPTER == 'invitations.models.InvitationsAdapter', see here.

Is this intended? Can it be changed so that I can subclass it and use ACCOUNT_ADAPTER = 'path.to.my.subclass'? Or is there a way to subclass InvitationsAdapter that I'm not seeing?

KeyError: '__module__' upon installation with Django 1.9

After installing version 0.8.0 and adding 'organizations' to INSTALLED_APPS I get the following traceback:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/runserver.py", line 109, in inner_run
    autoreload.raise_last_exception()
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 249, in raise_last_exception
    six.reraise(*_exception)
  File "/usr/local/lib/python2.7/dist-packages/django/utils/autoreload.py", line 226, in wrapper
    fn(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 202, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/usr/local/lib/python2.7/dist-packages/organizations/models.py", line 33, in <module>
    from .base import OrganizationBase, OrganizationUserBase, OrganizationOwnerBase
  File "/usr/local/lib/python2.7/dist-packages/organizations/base.py", line 146, in <module>
    class OrganizationBase(six.with_metaclass(OrgMeta, UnicodeMixin, models.Model)):
  File "/usr/lib/python2.7/dist-packages/six.py", line 617, in with_metaclass
    return meta("NewBase", bases, {})
  File "/usr/local/lib/python2.7/dist-packages/organizations/base.py", line 74, in __new__
    return super(OrgMeta, cls).__new__(cls, name, bases, attrs)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 81, in __new__
    module = attrs.pop('__module__')
KeyError: u'__module__'

This is the output of pip freeze:

alabaster==0.7.9
appnope==0.1.0
argh==0.26.2
Babel==2.3.4
backports-abc==0.4
backports.shutil-get-terminal-size==1.0.0
beautifulsoup4==4.5.1
certifi==2016.8.31
click==6.6
coverage==4.1
cssmin==0.2.0
cssprefixer==1.4.1
cssutils==1.0.1
decorator==4.0.10
Django==1.9.9
django-allauth==0.26.1
django-appconf==1.0.2
django-bootstrap-form==3.2.1
django-compressor==2.0
django-debug-toolbar==1.5
django-grappelli==2.8.1
django-organizations==0.8.0
django-phonenumber-field==1.1.0
docutils==0.12
enum34==1.1.6
flake8==2.6.2
Flask==0.11.1
Flask-Assets==0.12
gevent==1.0.2
gevent-socketio==0.3.6
gevent-websocket==0.9.5
greenlet==0.4.10
html5lib==0.999999999
imagesize==0.7.1
ipdb==0.10.1
ipython==5.0.0
ipython-genutils==0.1.0
itsdangerous==0.24
Jinja2==2.8
livereload==2.4.1
lockfile==0.12.2
Logbook==1.0.0
maildump==0.5.4
MarkupSafe==0.23
mccabe==0.5.2
oauthlib==2.0.0
passlib==1.6.5
pathlib==1.0.1
pathlib2==2.1.0
pathtools==0.1.2
pexpect==4.2.1
phonenumbers==7.6.0
phonenumberslite==7.6.0
pickleshare==0.7.4
port-for==0.3.1
prompt-toolkit==1.0.7
ptyprocess==0.5.1
pycodestyle==2.0.0
pyflakes==1.2.3
Pygments==2.1.3
pyScss==1.3.5
python-daemon==2.1.1
python-openid==2.2.5
pytz==2016.6.1
PyYAML==3.12
rcssmin==1.0.6
requests==2.11.1
requests-oauthlib==0.6.2
rjsmin==1.0.12
simplegeneric==0.8.1
singledispatch==3.4.0.3
six==1.10.0
snowballstemmer==1.2.1
Sphinx==1.4.6
sphinx-autobuild==0.6.0
sphinx-rtd-theme==0.1.9
sqlparse==0.2.1
tornado==4.4.1
traitlets==4.3.0
watchdog==0.8.3
wcwidth==0.1.7
webassets==0.12.0
webencodings==0.5
Werkzeug==0.11.11

I'm using Python 2.7.12.

If I remove 'organizations' from INSTALLED_APPS everything works again.

inviter not set when using SendInvite view

I would expected the inviter field of an Invitation to be set when using the SendInvite view since it requires a logged in user.

I think this just needs an extra line before sending the invite that sets:

invite.inviter = request.user
invite.save()

I'm willing to make a PR for this, if you can confirm this is the expected behavior. ๐Ÿ˜„

Using Invitation in forms

Hi,
I need use invite.send_invitation(request) in a forms, the problem is that request dont exist inside forms, there are other way to send invitations without request?
The same problem occour when a send in signals.
Regards.

Refactor into generic invite app

There's no reason for a dependency on all-auth and it's pretty trivial to refactor so this can be a generic invite app with pluggable backends.

INVITATIONS_ALLOWED_GROUPS is not optional

Hi,
It seems like running with INVITATIONS_ALLOWED_GROUPS=None (the default value) is not supported. the view at /invitations/send-invite/ raises the following exception:

ImproperlyConfigured at /invitations/send-invite/
SendInvite requires the "group_required" attribute to be set and be one of the following types: string, unicode, list or tuple```

Double form validation in SendInvite

In SendInvite view, in form_valid method self.get_context_data is called without form kwarg. Django (since 1.9.1, I think) creates new form instance in FormMixin in get_context_data method.

It's new instance and it does not have any errors initialized, and validation will be executed again on email.errors access in template. Template is rendered after invitation is created, so it fails with "already_invited" case, and this error is rendered. But invite is still sent.

My proposal is to add form=form kwarg to get_context_data, since this view is rendering on POST and not redirecting.

Unable to use different adapter when using allauth

It seems that the code around get_invitations_adapter breaks if ACCOUNT_ADAPTER is set, but is NOT equivalent to 'invitations.models.InvitationsAdapter'. In this case get_invitations_adapter returns None.

My use case is that I'm using allauth with allauth_2fa, which overrides the ACCOUNT_ADAPTER.

(Also, as an aside, I think the implementation of is_open_for_signup of InvitationsAdapter is equivalent to the DefaultAccountAdapter implementation.) They're inheriting from different models, never mind. ๐Ÿ‘

Group invitations

I had to recreate your app to handle invitations that auto-added the invited users to a set of groups.

Would this be an addition to the app of interest?

I basically just added a ManyToMany field called groups to the model and adjusted all templates/views/forms/admin to reflect the change.

New release

Could you issue a new release version for this project? We're trying to clean up all the deprecation warnings in our code and #59 will be very helpful for that when included in a release.

Needing help on how to implement the invitations with my event platform

Hi folks, i am using the allauth for login and signup and now i need to Invite people to my events.
I am thinking on how to do that, i have the following scheme: Event with 1:n relation with Attendee, as the event organizer i would like to invite other users to my event.

invitations-process

In my mind this a nice and simple worflow for this process, i dont want just the receiver of the invitation to become a user in my plataform but i need it to become a attendee of the event that he/she was invited.

In the coding i have a page for the organizer to send invites to emails. The users confirm they invitations and i would like to add that users to the organizer's event. I think on after the users login/sign up (in the populate_user method inside a CustomSocialAccountAdapter allauth adapter) i will look in the Invitation models for email of that user and if i found some invite i add that user to that event.

# attendee/custom_adapter.py

class CustomSocialAccountAdapter(DefaultSocialAccountAdapter):
    def populate_user(self, request, sociallogin, data):
        email = sociallogin.account.extra_data.get('email')
        user = User.objects.get(email=email)

        try:
            invite = Invitation.objects.get(email=email)
        except Invitation.DoesNotExist:
            pass
        else:
            if not invite.activity.attendees.filter(user=user).exists():
                Attendee.objects.create(
                    activity=activity,
                    profile=user.profile
                )

I tried to make this on the siganls but it is never called:

# attendee/models.py

from django.dispatch import receiver
from django.contrib.auth.models import AnonymousUser

from invitations.signals import invite_accepted

@receiver(invite_accepted, sender=AnonymousUser)
def invite_accepted(sender, request, email, **kwargs):
    ...

Can you folks help me telling me if there is a easiest way of doing this?

Thanks in advance.

Custom Email Template

Hi,

Is it possible to specify a custom email template for invitations? ideally I want an html template.

keep up the good work.

Posting via a URL

Instead of just having a form submission, is it possible to also post a URL? (enabling an ajax API).

Python 3 Support?

According to Django Packages this doesn't support Python 3. Is this true or not? If it is, I'm willing to make a PR updating it to support Python 3.

Keeping track of who sent the invite

Is this possible at the moment? It doesn't look like it's stored, and it doesn't get sent in the signals.

This is what passing it in the signal would look like (useful I think even if further down the line you decide to store it in the model:

models.py

signals.invite_url_sent.send_robust(
            sender=self.__class__,
            instance=self,
            invite_url_sent=invite_url,
            inviter=request.user)

signals.py

invite_url_sent = Signal(providing_args=['invite_url_sent', 'inviter'])
[...]
@receiver(invite_url_sent, sender=Invitation)
def invite_url_sent(sender, instance, invite_url_sent, inviter, **kwargs):
    pass

implementation:

@receiver(invite_url_sent, sender=Invitation)
def invite_url_sent(sender, instance, invite_url_sent, inviter, **kwargs):
    pass

If that looks right to you, I can do a PR with those changes.

Access invitation information in template?

I'm using django-invitations in combination with django-allauth, so after an invitation is accepted the user gets dumped into the standard registration workflow. This works great, but is a little confusing to users because it's not obvious that the invitation was actually accepted!

I know that django-invitation uses the messages framework to give an invite accepted message, but if you have ACCEPT_INVITE_AFTER_SIGNUP set to True, the accept_invitation code doesn't run until after registration.

Any idea of a way to customize the resulting registration template? Would it make sense to add the accepted invite to the session? Let me know if you have any ideas and I'll put together a PR (or if this doesn't seem like something to upstream, I'm looking for some guidance on how to do this custom in my app!). Thanks again for the great package!

Are there ways to integrate with social networks?

In addition to the invitation via e-mail, I'm looking for an opportunity to invite through the social network.
One of the options that I'm considering is the repost button, which would have some kind of get parameter. I completely understand how to do this separately from your application, but I want to unify the two solutions, and I'm looking for the shortest way for this.

No module named 'app_settings'

  File "/srv/python3/lib/python3.4/site-packages/invitations/urls.py", line 3, in <module>
    from . import views
  File "/srv/python3/lib/python3.4/site-packages/invitations/views.py", line 13, in <module>
    from app_settings import app_settings
ImportError: No module named 'app_settings'

django=1.8.2 python==3.4.2

Add Cancelled field on Invitation model

I'm using django-invitations (thanks btw!) and right now, I have functionality to cancel an invite (which right now deletes the Invitation). It would be nice if the Invitation model had a 'cancelled' boolean field which would allow me to soft-delete Invitations. Let me know what you think!

Advice on Customising the `Invitation` Model

Hi @bee-keeper,

Thanks for a great project. We use django-invitations in one live project and are looking to integrate it into another now.

Our current project requires that we have some custom fields on the Invitation model which will be used to render the email. We basically want a personal salutation.

Is there a generic, reusable way to do this? Trying to avoid forking the package.

edit: this is related to #50. closing

Trigger invitation acceptation even if different e-mail address signs up with allauth

If you enable ACCEPT_INVITE_AFTER_SIGNUP, the invitation to accept is looked up based on the e-mail address used to complete the signup. Because this field is editable (but pre-filled), it's possible the user enters a different e-mail address, and the original invitation will not be found and never marked as accepted.

In my case I have post-acceptance triggers that will give a user rights to edit a specific object. So user Alice will invite user Bob with the e-mail address [email protected], but if Bob follows the link and creates his account as [email protected], his invitation will not be marked as accepted and he can not get the necessary permissions.

I think a solution would be to store the invitation in the session (in the AcceptInvite view) and retrieve this actual invitation in the accept_invite_after_signup signal handler. The invite_accepted signal might then need to be changed as well: don't just send the e-mail address of the original invitation, but the e-mail address used to accept it as well.

Tracking the number of invited users

I need to be able to track how many users have been invited by a particular user.

What are the ways to do this?

We can assume that this is a kind of referral system.

I want to know what user this user was invited to.

Please give a brief recommendation on the implementation of this task.

For example:

user 123, user 124 and user 125 was invited by user 7.

Thanks!

Lack of documentation

Hey there! I am using your app, for a college project, and I am encountering issues at understanding the complete flow of the app because of the lack of documentation.

I applied the steps suggested in README.md (not using allauth) and "it works". But I cannot figure out how to make my site invite only, that is, I want SIGNUP_REDIRECT to be accesible only by clicking on an invitation link, I thought that was your INVITATION_ONLY config meant to, but it does not seem to do any logical change, I tried inspecting the source but didn't get too further.

So, I am here for advice, does your app support this??

Another thing, but it does not have to do with your app; from time to time, sending invitations crashes in SSLEOFError (or something like that) saying that there has been a protocol violation. I tested sending standalone mails, and that error also happened to raise some of the times.

That's it, I hope you can help me.
Regards!

Invite link url trailing slash not included in link - Android email

While the invite email link url's trailing slash is in the invite email, it is not included in the active link in my Android's email message so it gives 404 not found. This is a rare case but if trailing slash was not present then it wouldn't ever be an issue.

The url is built in model.py:
invite_url = request.build_absolute_uri(invite_url)

Not sure where trailing slash is being added. Does build_absolute_uri add it ? Documentation indicates it doesn't?

https://docs.djangoproject.com/en/1.8/ref/request-response/#django.http.HttpRequest.build_absolute_uri

NoReverseMatch Error in Django 2.0

Hi, I have an error using your package with django 2.0, it's unable to found the pattern for views! and throw me a NoReverseMatch error, that could be 'cause the URL format? or something similar?

Once the invitation link is clicked, even if the form is not submitted, a new click leads to a 404

Hi,
I am using allauth. The integration with django-invitations works perfectly.

However, I encounter a behaviour that seems strange to me. Once an invitation link is clicked, the invitation is 'accepted', even if the user doesn't submit a sign up form. So, if a user inadvertently closes the page and wants to reload it, it will find a 404 error.

Another related behaviour that I find strange, is the fact that a 404 is raised for previously "accepted" invites. I would like instead to display an error message like "Sorry this invitation has expired" or "Sorry this invitation has already been used"..

Can't find docs

I could find some sort of online docs, like readthedocs.io, which would be nice. More specifically I need to extend the creation of new invitations which I think I can do using the INVITATIONS_INVITATION_MODEL setting. But it's a bit unclear how this should be done, and how a custom adapter should be used as well.

TL;DR It would be nice with readthedocs.io style online documentation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.