Example #1
0
    def clean(self):

        # github.com/omab/python-social-auth/commit/d8637cec02422374e4102231488481170dc51057
        if isinstance(User, six.string_types):
            app_label, model_name = User.split('.')
            UserModel = models.get_model(app_label, model_name)  

        try:
            self.apply(UserModel.objects.all())
        except Exception as e:
            raise ValidationError(
                '%s raised trying to apply rule: %s' % (type(e).__name__, e))
Example #2
0
    def queryset(self):
        """
        Returns a queryset of auth.User who meet the
        criteria of the drip.

        Alternatively, you could create Drips on the fly
        using a queryset builder from the admin interface...
        """

        # github.com/omab/python-social-auth/commit/d8637cec02422374e4102231488481170dc51057
        if isinstance(User, six.string_types):
            app_label, model_name = User.split('.')
            UserModel = models.get_model(app_label, model_name)  
            return UserModel.objects      

        return User.objects
Example #3
0
    def view_drip_email(self, request, drip_id, into_past, into_future, user_id):
        from django.shortcuts import render, get_object_or_404
        from django.http import HttpResponse
        drip = get_object_or_404(Drip, id=drip_id)

        if isinstance(User, six.string_types):
            app_label, model_name = User.split('.')
            UserModel = models.get_model(app_label, model_name)

        user = get_object_or_404(UserModel, id=user_id)
        drip_message = message_class_for(drip.message_class)(drip.drip, user)

        html = ''
        for body, mime in drip_message.message.alternatives:
            if mime == 'text/html':
                html = body

        return HttpResponse(html)