Пример #1
0
def add_invited(user):
    print "ADD INVITED SUBSCRIPTIONS"
    ## Add to subscription list

    # get newsletter
    try:
        newsl = Newsletter.objects.get(slug='emif-catalogue-newsletter')

        # create subscription
        user_sub = Subscription(user=user,  newsletter=newsl)

        user_sub.subscribe()

        user_sub.save()

    except Newsletter.DoesNotExist:
        print "Problem registering new user to emif default newsletter"

    # add invited dbs if any
    sps = InvitePending.objects.filter(email=user.email)

    for sp in sps:

        fingerprint = sp.fingerprint

        fingerprint.save()

        fingerprint.shared.add(user)

        sp.delete()

        # must reindex, because databases lists come from solr, to update user_t
        fingerprint.indexFingerprint()
Пример #2
0
def add_invited(user):
    print "ADD INVITED SUBSCRIPTIONS"
    ## Add to subscription list

    # get newsletter
    try:
        newsl = Newsletter.objects.get(slug='emif-catalogue-newsletter')

        # create subscription
        user_sub = Subscription(user=user, newsletter=newsl)

        user_sub.subscribe()

        user_sub.save()

    except Newsletter.DoesNotExist:
        print "Problem registering new user to emif default newsletter"

    # add invited dbs if any
    sps = InvitePending.objects.filter(email=user.email)

    for sp in sps:

        fingerprint = sp.fingerprint

        fingerprint.save()

        fingerprint.shared.add(user)

        sp.delete()

        # must reindex, because databases lists come from solr, to update user_t
        fingerprint.indexFingerprint()
Пример #3
0
def importUsers():

    try:
        newsl = Newsletter.objects.get(slug='emif-catalogue-newsletter')


        users = User.objects.all()

        for user in users:
            try:
                subscription = Subscription.objects.get(user=user,  newsletter=newsl)

            except Subscription.DoesNotExist:
                # create subscription if doesnt exist yet
                user_sub = Subscription(user=user,  newsletter=newsl)

                user_sub.subscribe()

                user_sub.save()

                print "-- Created subscription for emif newsletter to user "+str(user.username)

                pass

    except Newsletter.DoesNotExist:
        print "Problem finding default newsletter for emif"
Пример #4
0
    def setNewsletterSubs(self, new_status):
        newsl = self.getNewsletter()

        newsl_sub = None
        try:
            newsl_sub = Subscription.objects.get(user=self.user,  newsletter=newsl)
        except Subscription.DoesNotExist:
            newsl_sub = Subscription(user=self.user, newsletter = newsl)

        if(new_status):
            newsl_sub.subscribe()
        else:
            newsl_sub.unsubscribe()

        newsl_sub.save()
Пример #5
0
    def setNewsletterSubs(self, new_status):
        newsl = self.getNewsletter()

        newsl_sub = None
        try:
            newsl_sub = Subscription.objects.get(user=self.user,
                                                 newsletter=newsl)
        except Subscription.DoesNotExist:
            newsl_sub = Subscription(user=self.user, newsletter=newsl)

        if (new_status):
            newsl_sub.subscribe()
        else:
            newsl_sub.unsubscribe()

        newsl_sub.save()