Skip to content

Commit

Permalink
added max_allowed_violations
Browse files Browse the repository at this point in the history
  • Loading branch information
Pancham1603 committed Dec 13, 2023
1 parent 2923748 commit 09236d6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.7 on 2023-12-13 01:37

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('global_settings', '0002_settings_enable_gender_ratio_settings_female_ratio_and_more'),
]

operations = [
migrations.AlterModelOptions(
name='settings',
options={'verbose_name_plural': 'Settings'},
),
migrations.AddField(
model_name='settings',
name='max_violation_count',
field=models.IntegerField(blank=True, default=3, null=True),
),
]
2 changes: 2 additions & 0 deletions apps/global_settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Settings(models.Model):
enable_gender_ratio = models.BooleanField(default=False)
male_ratio = models.FloatField(blank=True, null=True, default=0.5)
female_ratio = models.FloatField(blank=True, null=True, default=0.5)

max_violation_count = models.IntegerField(blank=True, null=True, default=3)

class Meta:
verbose_name_plural = 'Settings'
6 changes: 6 additions & 0 deletions apps/nightpass/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ def generate_pass(request, campus_resource):
}
return HttpResponse(json.dumps(data))

if user.student.violation_flags > Settings.max_violation_count:
data = {
'status':False,
'message':'Nightpass facility has been temporarily suspended! Contact DOSA office for further details.'
}
return HttpResponse(json.dumps(data))

user_pass = NightPass.objects.filter(user=user, date=date.today()).first()
if not user_pass:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 4.2.7 on 2023-12-13 01:37

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('users', '0008_student_gender_alter_nightpass_valid'),
]

operations = [
migrations.AlterModelOptions(
name='nightpass',
options={'verbose_name_plural': 'Night Passes'},
),
migrations.AlterModelOptions(
name='security',
options={'verbose_name_plural': 'Security'},
),
]

0 comments on commit 09236d6

Please sign in to comment.