示例#1
0
def payment_notification(sender, **kwargs):
    ipn = sender
    if ipn.payment_status == 'Completed':
        # payment was successful

        profile = Profile.objects.get(user_id=ipn.invoice)
        Referral.record_response(request, "PAID")

        profile.paid = True
        profile.save()
示例#2
0
def createUser(request):
    if request.method == 'GET':
        user_form = SignUpForm()
        return render(request, 'sign_up.html', {'user_form': user_form})
    elif request.method == 'POST':
        user_form = SignUpForm(request.POST)
        message = "User created successfully"
        if user_form.is_valid():
            #validate user email
            email = user_form.cleaned_data['email']
            mail_response = validate_email(email)

            disposable = mail_response['is_disposable_address']  #disposable
            if (disposable == True):
                errors = user_form.add_error(
                    "email", "Email " + str(email) +
                    " seems to be disposable, use another one.")
                data = {'user_form': user_form}
                return render(request, 'sign_up.html', data)

            user = user_form.save(commit=False)
            user.is_active = True
            user.username = user.username.lower().strip()
            user.save()
            referral_response = Referral.record_response(request,
                                                         "SIGN_UP",
                                                         target=user)
            send_confirmation_email(request, user)
            return render(request, 'account_activation_sent.html',
                          {'email': email})
        return render(request, 'sign_up.html', {'user_form': user_form})
    raise ValueError('Not valid request at signup')
示例#3
0
def handle_user_signed_up(sender, request, user, **kwargs):
    referral_response = Referral.record_response(request, "SIGN_UP")
    print(referral_response)
    profile = user.profile
    referral = Referral.create(user=user, redirect_to=reverse_lazy('home'))
    profile.referral = referral
    profile.save()
示例#4
0
def save_profile(sender, **kwargs):
    request = kwargs['request']
    user = kwargs['user']
    print(user)

    referral = Referral.create(
        user=user,
        redirect_to=reverse("Home:afterclickin"),
        label="SIGNED_UP",
    )

    Referral.record_response(request, "SIGNED_UP")

    profile = Profile.objects.create(user=user, referral=referral)

    profile.save()
示例#5
0
 def after_signup(self, form):
     self.create_profile(form)
     super(SignupView, self).after_signup(form)
     action = Referral.record_response(self.request, "USER_SIGNUP")
     if action is not None:
         referral = Referral.objects.get(id=action.referral.id)
         profile = Profile.objects.get(user=self.created_user)
         profile.parent = Profile.objects.get(user=referral.user)
         profile.save()
示例#6
0
    async def websocket_receive(self, event):
        print("received", event)
        front_end = event.get("text", None)
        if front_end is not None:
            data = json.loads(front_end)
            user = data.get('user')
            # request = data.get("request")
            # print(request, "this is request")
            await self.send({
                "type": "websocket.send",
                "text": f"imekubali {user}"
            })

            profile = Profile.objects.get(user__username=user, paid=False)
            print(profile, "checking if profile is not none")
            profile.paid = True
            profile.save()

            request = dot(self.scope)
            Referral.record_response(request, "PAID")
示例#7
0
def validate_mpesa_code(request):
    profile = Profile.objects.filter(user=request.user, paid=False).first()
    # amount = order.get_total()
    data = {}
    mpesa_code = request.GET.get('mpesa_code', None)
    if profile:
        if mpesa_code:
            result1 = LNMOnline.objects.filter(
                MpesaReceiptNumber__iexact=mpesa_code, paid=False).exists()

            if result1 == True:

                result = LNMOnline.objects.get(MpesaReceiptNumber=mpesa_code,
                                               paid=False)

                result.paid = True

                result.save()

                Referral.record_response(request, "PAID")
                profile.paid = True
                profile.save()

                data["message"] = "Transaction Successful"

                return JsonResponse(data)

            else:

                data["message"] = "Mpesa Code Does not exist"

                return JsonResponse(data)
        else:
            data["message"] = "Enter Mpesa Code"

            return JsonResponse(data)
    else:

        data["message"] = "user does not exist"

        return JsonResponse(data)
示例#8
0
def handle_user_signed_up(sender, request, user, **kwargs):
    profile = user.profile
    referral = Referral.create(user=user,
                               redirect_to=reverse_lazy('rest_register'))
    profile.referral = referral
    action = Referral.record_response(request, "USER_SIGNUP")
    if action is not None:
        referra = Referral.objects.get(id=action.referral.id)
        print(referra.user.id)
        profile.referredBy = User.objects.get(id=referra.user.id)
        profile.save()
    profile.save()
示例#9
0
def home(request):
    context = {
        "title": "eLearning",
    }
    action = Referral.record_response(request, "login")

    respo = render(request, "home.html", context)

    if action is not None:
        referral = Referral.objects.get(id=action.referral.id)
        respo.set_cookie('parent', referral.user.username)

    return respo
示例#10
0
文件: views.py 项目: kshutashvili/gnc
def registration(request):
    if request.method == 'POST':
        register_form = RegistrationForm(request.POST)
        response_data = {}
        if register_form.is_valid():
            register_form.save()
            cd = register_form.cleaned_data

            # before authentication and login!
            Referral.record_response(request, action_string="USER_SIGNUP")

            user = authenticate(username=cd['username'], password=cd['password1'])
            login(request, user)

            response_data['success'] = True
            response_data['message'] = _("Вы успешно зарегистрировались")
            # return HttpResponse(json.dumps(response_data), content_type="application/json")
            return HttpResponseRedirect(reverse('profile'))
        else:
            # print register_form.errors
            response_data['success'] = False
            response_data['message'] = register_form.errors
            return HttpResponse(json.dumps(response_data), content_type="application/json")
    return HttpResponseBadRequest()
示例#11
0
文件: views.py 项目: kshutashvili/gnc
def save_transaction(request):
    if request.method == 'POST':
        form = DonationForm(request, request.POST)
        response_data = {}

        if form.is_valid():
            if form.cleaned_data["payment_method"] != Donation.PAYMENT_METHOD.ETH \
               and not form.cleaned_data["tx_id"]:

                response_data['transaction_error'] = {}
                response_data['transaction_error']['tx_id'] = [
                    str(_("Для не ETH транзакций это поле обязательно"))
                ]

                return HttpResponse(json.dumps(response_data),
                                    content_type="application/json")
            else:
                donat_obj = form.save()

                # creating referral response
                ref_response_obj = Referral.record_response(
                    request, action_string="PURCHASED")

                # linking referral response with donation
                if ref_response_obj:
                    donat_obj.ref_response = ref_response_obj
                    donat_obj.save()

                response_data['message'] = str(_('Transaction saved!'))
                response_data['donation_obj'] = {
                    'date': donat_obj.created_dt.strftime("%d.%m.%y"),
                    'method': donat_obj.payment_method
                }
                return HttpResponse(json.dumps(response_data),
                                    content_type="application/json")
        else:
            response_data['transaction_error'] = form.errors
            return HttpResponse(json.dumps(response_data),
                                content_type="application/json")
    else:
        return HttpResponseBadRequest()
示例#12
0
def record_referrer_response(request, action):
    """
    Here we give credit to the referrer
    """
    return Referral.record_response(request, action)
示例#13
0
def count_referral(request, is_new, **kwargs):
    if is_new:
        Referral.record_response(request, 'REGISTER')