Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions training/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
12 changes: 5 additions & 7 deletions training/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
28 changes: 28 additions & 0 deletions training/migrations/0025_auto_20260128_1441.py
Original file line number Diff line number Diff line change
@@ -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),
),
]
30 changes: 19 additions & 11 deletions training/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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')
Expand Down
7 changes: 6 additions & 1 deletion training/templates/list_event_participants.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
From Subscribed college
{% elif record.participant.registartion_type >= 2 %}
Manual registartion

{% endif %}
</td>
<td><strong>
Expand All @@ -96,8 +97,12 @@
From Host college
{% elif record.registartion_type == 1 %}
From Subscribed college
{% elif record.registartion_type >= 2 %}
{% elif record.registartion_type == 2 %}
Manual registartion
{% elif record.registartion_type == 3 %}
Self Subscribed
{% elif record.registartion_type == 4 %}
Self Registration
{% endif %}
</td>
<td>
Expand Down
26 changes: 11 additions & 15 deletions training/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ def reg_success(request, user_type):
form_data = form.save(commit=False)
form_data.user = request.user
form_data.event = event
form_data.added_by = request.user


if source == 'deet':
form_data.source = source
Expand All @@ -340,9 +342,9 @@ def reg_success(request, user_type):
pass
user_data = is_user_paid(form_data.college.id)
if user_data:
form_data.registartion_type = 1 #Subscribed College
form_data.registartion_type = 3
else:
form_data.registartion_type = 2 #Manual reg- paid 500
form_data.registartion_type = 4

part = Participant.objects.filter(
Q(payment_status__status = 1)|Q(registartion_type__in = (1,3)),
Expand Down Expand Up @@ -575,10 +577,6 @@ def get_context_data(self, **kwargs):
def form_valid(self, form):
count = 0
csv_file_data = form.cleaned_data['csv_file']
registartion_type = form.cleaned_data['registartion_type']
if registartion_type == 2:
# 3 - Manual Registration via CSV(option not visible outside)
registartion_type = 3
rows_data = csv.reader(csv_file_data, delimiter=',', quotechar='|')
csv_error = False
user_errors = []
Expand All @@ -591,12 +589,10 @@ def form_valid(self, form):
csv_error = True
messages.add_message(self.request, messages.ERROR, "Row: "+ str(i+1) + " Institution name " + row[6] + " does not exist."+" Participant "+ row[2] + " was not created.")
continue

if registartion_type == 1:
if not(is_college_paid(college.id)):
messages.add_message(self.request, messages.ERROR, "Row: "+ str(i+1) + " Institution " + row[6] + " is not a Paid college."+" Participant "+ row[2] + " was not created.")
continue

if is_college_paid(college.id):
registartion_type = 1 # Subscribed College
else:
registartion_type = 2
try:
foss_language = Language.objects.get(name=row[7].strip())
except :
Expand All @@ -620,7 +616,8 @@ def form_valid(self, form):
college = college,
foss_language = foss_language,
registartion_type = registartion_type,
reg_approval_status = 1
reg_approval_status = 1,
added_by = self.request.user
)
count = count + 1
except :
Expand Down Expand Up @@ -670,7 +667,6 @@ def get_create_user(self, row):
return User.objects.filter(Q(email=email) | Q(username=email)).first()
return None


def mark_reg_approval(pid, eventid):
participant = Participant.objects.get(event_id =eventid, id=pid)
participant.reg_approval_status = 1
Expand All @@ -686,7 +682,7 @@ def dispatch(self, *args, **kwargs):
self.event = TrainingEvents.objects.get(pk=kwargs['eventid'])
main_query = Participant.objects.filter(event_id=kwargs['eventid'])

self.queryset = main_query.filter(Q(payment_status__status=1)| Q(registartion_type__in=(1,3)) | Q(payment_status__transaction__order_status="CHARGED"))
self.queryset = main_query.filter(Q(payment_status__status=1)| Q(registartion_type__in=(1,2,3)) | Q(payment_status__transaction__order_status="CHARGED"))
self.unsuccessful_payee = main_query.filter(Q(payment_status__status__in=(0,2)) & ~Q(payment_status__transaction__order_status="CHARGED"))
if self.event.training_status == 1:
self.queryset = main_query.filter(reg_approval_status=1)
Expand Down