diff --git a/cms/views.py b/cms/views.py index 8ac072783..6953fc5b6 100644 --- a/cms/views.py +++ b/cms/views.py @@ -62,11 +62,13 @@ def dispatcher(request, permalink=''): def create_profile(user, phone): - confirmation_code = ''.join(random.choice(string.ascii_uppercase + string.digits + string.ascii_lowercase) for x in range(7)) + confirmation_code = create_confirmation_code() profile = Profile(user=user, confirmation_code=confirmation_code, phone=phone) profile.save() return profile +def create_confirmation_code(): + return ''.join(random.choice(string.digits) for x in range(6)) def account_register(request): # import recaptcha validate function diff --git a/donate/migrations/0011_payee_callbackurl.py b/donate/migrations/0011_payee_callbackurl.py new file mode 100644 index 000000000..b18f7f5f6 --- /dev/null +++ b/donate/migrations/0011_payee_callbackurl.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11 on 2024-11-27 06:13 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('donate', '0010_auto_20240903_1819'), + ] + + operations = [ + migrations.AddField( + model_name='payee', + name='callbackurl', + field=models.CharField(default=None, max_length=500, null=True), + ), + ] diff --git a/donate/models.py b/donate/models.py index 71e0c4ae4..e340fc670 100644 --- a/donate/models.py +++ b/donate/models.py @@ -25,6 +25,7 @@ class Payee(models.Model): purpose = models.CharField(max_length=255, null=True) reqId = models.CharField(max_length=100, default='') source = models.CharField(max_length=25, null=True, default=None) + callbackurl = models.CharField(max_length=500, null=True, default=None) def get_selected_foss(self): selected_foss = {} c = 0 diff --git a/donate/views.py b/donate/views.py index c18713aca..077334d35 100644 --- a/donate/views.py +++ b/donate/views.py @@ -11,7 +11,7 @@ from django.template.context_processors import csrf from donate.forms import PayeeForm, TransactionForm from donate.models import * -from cms.views import create_profile, email_otp,send_registration_confirmation +from cms.views import create_profile, email_otp,send_registration_confirmation, create_confirmation_code from django import forms from django.views.decorators.csrf import csrf_protect, csrf_exempt from django.contrib.auth.mixins import LoginRequiredMixin @@ -126,8 +126,10 @@ def form_valid(request, form, purpose): form_data.expiry = calculate_expiry() form_data.purpose = purpose source = request.POST.get('source') + callbackurl = request.POST.get('callbackurl') if source == 'deet': form_data.source = 'deet' + form_data.callbackurl = callbackurl form_data.save() payee_obj = form_data # Save CdFossLanguages record @@ -191,14 +193,20 @@ def controller(request, purpose): participant_form.save() except : return redirect('training:list_events', status='myevents') - data = get_final_data(request, payee_obj_new, purpose) + final_data = get_final_data(request, payee_obj_new, purpose) if payee_obj_new.source == 'deet': callbackurl = request.POST.get('callbackurl') - json = {'id': f'p{payee_obj_new.id}', 'name': payee_obj_new.name, - 'email':payee_obj_new.email, 'paid college': False, - 'amount': payee_obj_new.amount, 'status': 0} - requests.post(callbackurl, json) - return render(request, 'payment_status.html', data) + headers = {"Content-Type": "application/json; charset=utf-8"} + data = { + "id": f"p{payee_obj_new.id}", + "name": payee_obj_new.name, + "email":payee_obj_new.email, + "paid college": False, + "amount": payee_obj_new.amount, + "status": 0 + } + response = requests.post(callbackurl, headers=headers, json=data) + return render(request, 'payment_status.html', final_data) @csrf_exempt @@ -269,6 +277,10 @@ def send_onetime(request): else: send_registration_confirmation(user) context['message'] = "inactive_user" + profile = Profile.objects.get(user=user) + profile.confirmation_code = create_confirmation_code() + profile.save() + email_otp(user) except MultipleObjectsReturned as e: pass diff --git a/events/viewsv2.py b/events/viewsv2.py index beea2056c..49bc7b9e2 100755 --- a/events/viewsv2.py +++ b/events/viewsv2.py @@ -2936,6 +2936,19 @@ def update_status(pd, status): pd.status = 2 pd.description = 'Payment fail' pd.save() + if pd.source == 'deet': + callbackurl = pd.callbackurl + headers = {"Content-Type": "application/json; charset=utf-8"} + data = { + "id": f"{pd.id}", + "name": pd.name, + "email":pd.email, + "paid college": False, + "amount": pd.amount, + "status": pd.status + } + response = requests.post(callbackurl, headers=headers, json=data) + def payment_details(request,choice): academic_id = Accountexecutive.objects.filter(user = request.user).values('academic_id','academic_id__institution_name') @@ -3565,4 +3578,4 @@ def form_valid(self, form, **kwargs): ac_key.save() messages.success(self.request, "Payment Details for academic is added successfully.") - return HttpResponseRedirect(self.success_url) \ No newline at end of file + return HttpResponseRedirect(self.success_url) diff --git a/static/cdcontent/js/cdcontent.js b/static/cdcontent/js/cdcontent.js index 131d975cf..1d0d48acd 100644 --- a/static/cdcontent/js/cdcontent.js +++ b/static/cdcontent/js/cdcontent.js @@ -184,7 +184,7 @@ $(document).ready(function(){ var otp = $('#otp_value').val(); var email = $('#id_email').val(); - if(otp.length>6){ + if(otp.length > 5){ $.ajax({ url:"/donate/validate", type:"POST", @@ -279,13 +279,6 @@ function delete_foss(elem){ $('.add_foss_lang').show(); } -function send_otp(){ - $("#send_otp").show(); - document.getElementById("otp_sent_msg").innerHTML = "OTP sent"; - document.getElementById('otp_sent_msg').className = 'label label-success'; - $("#otp_value").show(); - $("#otp_sent_msg").show().delay(10000).fadeOut(); -} function show_added_foss(selected_foss){ $.ajax({ diff --git a/training/templates/register_user.html b/training/templates/register_user.html index 87619432e..e19be045f 100644 --- a/training/templates/register_user.html +++ b/training/templates/register_user.html @@ -52,7 +52,9 @@