diff --git a/training/forms.py b/training/forms.py index 45206aa65..8173c3073 100644 --- a/training/forms.py +++ b/training/forms.py @@ -161,6 +161,15 @@ class UploadParticipantsForm(forms.ModelForm): class Meta(object): model = Participant fields = ['registartion_type'] + + def __init__(self, *args, **kwargs): + super(UploadParticipantsForm, self).__init__(*args, **kwargs) + + # ✅ Show only these two options in dropdown + self.fields['registartion_type'].choices = [ + (1, 'Subscribed College'), + (2, 'Manual Registration'), + ] def clean_csv_file(self): data = self.cleaned_data["csv_file"] diff --git a/training/helpers.py b/training/helpers.py index d74239fe7..4cbbdacb4 100644 --- a/training/helpers.py +++ b/training/helpers.py @@ -47,13 +47,11 @@ def handle_uploaded_file(request): def is_college_paid(college_id): - try: - idcase = AcademicKey.objects.filter(academic_id=college_id).order_by('-expiry_date').first() - college_paid = True if (idcase.expiry_date >= date.today()) else False - return college_paid - except Exception as e: - college_paid = False - return college_paid + idcase = AcademicKey.objects.filter(academic_id=college_id).order_by('-expiry_date').first() + if not idcase: + return False + return idcase.expiry_date >= date.today() + def create_certificate(eventid,pname): response = HttpResponse(content_type='application/pdf') diff --git a/training/migrations/0025_auto_20260128_1441.py b/training/migrations/0025_auto_20260128_1441.py new file mode 100644 index 000000000..de35670a6 --- /dev/null +++ b/training/migrations/0025_auto_20260128_1441.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2026-01-28 09:11 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('training', '0024_auto_20250825_1351'), + ] + + operations = [ + migrations.AddField( + model_name='participant', + name='added_by', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='participants_added', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='participant', + name='registartion_type', + field=models.PositiveSmallIntegerField(choices=[('', '-----'), (1, 'Subscribed College'), (2, 'Manual Registration'), (3, 'Self Subscribed'), (4, 'Self Registration')], default=1), + ), + ] diff --git a/training/models.py b/training/models.py index 2006a860c..f414b36de 100755 --- a/training/models.py +++ b/training/models.py @@ -18,7 +18,9 @@ REGISTRATION_TYPE_CHOICES =( - ('', '-----'), (1, 'Subscribed College'),(2, 'Manual Registration') + ('', '-----'), (1, 'Subscribed College'),(2, 'Manual Registration'), + (3, 'Self Subscribed'), + (4, 'Self Registration'), ) class CompanyType(models.Model): @@ -102,23 +104,29 @@ class Participant(models.Model): company = models.ForeignKey(Company, on_delete=models.PROTECT, null=True, blank=True) city = models.ForeignKey(City, on_delete=models.PROTECT, null=True, blank=True) source = models.CharField(max_length=25, null=True, default=None) + added_by = models.ForeignKey(User,on_delete=models.PROTECT,null=True,blank=True,related_name='participants_added') @property def payment_status_message(self): ps = self.payment_status - if not ps: + if self.registartion_type in (1, 2): return "CSV Upload" - if ps: - payee_status = ps.status # asc method - transaction_status = ps.transaction.order_status if ps.transaction else "" #hdfc gateway + if self.registartion_type == 3: + return "Individual- Subscribed College" + if self.registartion_type == 4 and ps: + payee_status = ps.status + transaction_status = ps.transaction.order_status if ps.transaction else "" if payee_status == 1 or transaction_status == "CHARGED": - return "Payment successfully completed 1" - if payee_status == 2 and transaction_status in ["FAILED", "AUTHENTICATION_FAILED", "AUTHORIZATION_FAILED"]: - return "Payment failed 1" - if payee_status == 0 : - return "Payment Initiated, not paid 1" - return "CSV Upload" + return "Individual- Non-Subscribed College" + if payee_status == 2 and transaction_status in [ + "FAILED", "AUTHENTICATION_FAILED", "AUTHORIZATION_FAILED" + ]: + return "Payment failed" + if payee_status == 0: + return "Payment Initiated, not paid" + return "" + class Meta(object): unique_together = ('event', 'user', 'payment_status') diff --git a/training/templates/list_event_participants.html b/training/templates/list_event_participants.html index df24ea976..7d1c53bcd 100644 --- a/training/templates/list_event_participants.html +++ b/training/templates/list_event_participants.html @@ -72,6 +72,7 @@ From Subscribed college {% elif record.participant.registartion_type >= 2 %} Manual registartion + {% endif %}