diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..f03e2f209448f4c150ca25951c67b0c267ca63ad --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3 +WORKDIR /usr/src/app +COPY requirements.txt ./ +RUN pip install -r requirements.txt +COPY . . +EXPOSE 7860 +CMD ["python","./app.py","runserver","0.0.0.0:7860"] \ No newline at end of file diff --git a/manage.py b/manage.py new file mode 100644 index 0000000000000000000000000000000000000000..0624d734f4e7a0035eca4d448df99d124591279c --- /dev/null +++ b/manage.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python +"""Django's command-line utility for administrative tasks.""" +import os +import sys + +def main(): + """Run administrative tasks.""" + os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sports_portal.settings') + try: + from django.core.management import execute_from_command_line + except ImportError as exc: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) from exc + execute_from_command_line(sys.argv) + + +if __name__ == '__main__': + main() diff --git a/registration/__init__.py b/registration/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/registration/__pycache__/__init__.cpython-310.pyc b/registration/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..94c2920a621af980d5012f6be044b595a38a72f5 Binary files /dev/null and b/registration/__pycache__/__init__.cpython-310.pyc differ diff --git a/registration/__pycache__/__init__.cpython-311.pyc b/registration/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fca507ee11ca771f20678b79032f0ca25306e5f3 Binary files /dev/null and b/registration/__pycache__/__init__.cpython-311.pyc differ diff --git a/registration/__pycache__/__init__.cpython-312.pyc b/registration/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bb69dffac95fbf1f5bb4bb5a0fd15d2411fc2f87 Binary files /dev/null and b/registration/__pycache__/__init__.cpython-312.pyc differ diff --git a/registration/__pycache__/__init__.cpython-313.pyc b/registration/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4302fc0c0e0ff1ed827eec57c5671c23164ae1ee Binary files /dev/null and b/registration/__pycache__/__init__.cpython-313.pyc differ diff --git a/registration/__pycache__/admin.cpython-310.pyc b/registration/__pycache__/admin.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bdae43aba4779174ccb59acde686577f699f2a2e Binary files /dev/null and b/registration/__pycache__/admin.cpython-310.pyc differ diff --git a/registration/__pycache__/admin.cpython-311.pyc b/registration/__pycache__/admin.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b73efbb1b1f4d8088fb58387cf0b2112e3e3b5c0 Binary files /dev/null and b/registration/__pycache__/admin.cpython-311.pyc differ diff --git a/registration/__pycache__/admin.cpython-312.pyc b/registration/__pycache__/admin.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f4f7b7e7ccd12171dc94688556228dd2d4518b5d Binary files /dev/null and b/registration/__pycache__/admin.cpython-312.pyc differ diff --git a/registration/__pycache__/admin.cpython-313.pyc b/registration/__pycache__/admin.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9738f3e0d94f03a6dc8eed942bd2e1ea20660a5 Binary files /dev/null and b/registration/__pycache__/admin.cpython-313.pyc differ diff --git a/registration/__pycache__/apps.cpython-310.pyc b/registration/__pycache__/apps.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2210367da90c03cbf9eb1739b0acba628ac06b92 Binary files /dev/null and b/registration/__pycache__/apps.cpython-310.pyc differ diff --git a/registration/__pycache__/apps.cpython-311.pyc b/registration/__pycache__/apps.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5d914563fb58fe9e079bc6673550573e35b4e386 Binary files /dev/null and b/registration/__pycache__/apps.cpython-311.pyc differ diff --git a/registration/__pycache__/apps.cpython-312.pyc b/registration/__pycache__/apps.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..baa3b564d41d035ddcada7d7fa7760c52c0a6f43 Binary files /dev/null and b/registration/__pycache__/apps.cpython-312.pyc differ diff --git a/registration/__pycache__/apps.cpython-313.pyc b/registration/__pycache__/apps.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fe85e29a1f0dd349f6e78e99ae89fb24172ae598 Binary files /dev/null and b/registration/__pycache__/apps.cpython-313.pyc differ diff --git a/registration/__pycache__/models.cpython-310.pyc b/registration/__pycache__/models.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..85b77d1579ea90391361d03d6a42aaffb7c03b76 Binary files /dev/null and b/registration/__pycache__/models.cpython-310.pyc differ diff --git a/registration/__pycache__/models.cpython-311.pyc b/registration/__pycache__/models.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1680fff8900c6df8e1a7a59cedf2cdddaf618cd7 Binary files /dev/null and b/registration/__pycache__/models.cpython-311.pyc differ diff --git a/registration/__pycache__/models.cpython-312.pyc b/registration/__pycache__/models.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..137aa44ac659b058baf68433ae93d23533355a68 Binary files /dev/null and b/registration/__pycache__/models.cpython-312.pyc differ diff --git a/registration/__pycache__/models.cpython-313.pyc b/registration/__pycache__/models.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1bc09ef0d51779537ee8f38118a06b47337feceb Binary files /dev/null and b/registration/__pycache__/models.cpython-313.pyc differ diff --git a/registration/__pycache__/urls.cpython-310.pyc b/registration/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b9eefb0e7fa4fc87cffacda52a37cb28c78ecca Binary files /dev/null and b/registration/__pycache__/urls.cpython-310.pyc differ diff --git a/registration/__pycache__/urls.cpython-311.pyc b/registration/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..30a184ec4eeb02fdea16f5d9b9e11a90ebc761a3 Binary files /dev/null and b/registration/__pycache__/urls.cpython-311.pyc differ diff --git a/registration/__pycache__/urls.cpython-312.pyc b/registration/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f6a665e61f8806dfd9da52e148f6a33c3dcd39df Binary files /dev/null and b/registration/__pycache__/urls.cpython-312.pyc differ diff --git a/registration/__pycache__/urls.cpython-313.pyc b/registration/__pycache__/urls.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d0e25dc46ad27a3611fa03f1034b42b0aaa8d002 Binary files /dev/null and b/registration/__pycache__/urls.cpython-313.pyc differ diff --git a/registration/__pycache__/views.cpython-310.pyc b/registration/__pycache__/views.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6a84e480842573425b3df53c686925fa77fa19e7 Binary files /dev/null and b/registration/__pycache__/views.cpython-310.pyc differ diff --git a/registration/__pycache__/views.cpython-311.pyc b/registration/__pycache__/views.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1fd260c3d8ea807d22b51e6f1ca4ae1c01870d06 Binary files /dev/null and b/registration/__pycache__/views.cpython-311.pyc differ diff --git a/registration/__pycache__/views.cpython-312.pyc b/registration/__pycache__/views.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..649cc170a652087015401c9d303451f7a9344784 Binary files /dev/null and b/registration/__pycache__/views.cpython-312.pyc differ diff --git a/registration/__pycache__/views.cpython-313.pyc b/registration/__pycache__/views.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..5848cd9cd10363388ffb4e43c27324987422f864 Binary files /dev/null and b/registration/__pycache__/views.cpython-313.pyc differ diff --git a/registration/admin.py b/registration/admin.py new file mode 100644 index 0000000000000000000000000000000000000000..ea5d68b7c457cb7f92da9c00a5c4df77ace36cef --- /dev/null +++ b/registration/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/registration/apps.py b/registration/apps.py new file mode 100644 index 0000000000000000000000000000000000000000..a339ee6772d56ec0c55e96060d9380b637200362 --- /dev/null +++ b/registration/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class RegistrationConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'registration' diff --git a/registration/migrations/0001_initial.py b/registration/migrations/0001_initial.py new file mode 100644 index 0000000000000000000000000000000000000000..90db618622eec06a878543054c6a1226820b5910 --- /dev/null +++ b/registration/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# Generated by Django 5.1.4 on 2025-01-29 18:24 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Game', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('gender', models.CharField(choices=[('M', 'Male'), ('F', 'Female')], max_length=1)), + ], + ), + migrations.CreateModel( + name='Registration', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=100)), + ('email', models.EmailField(max_length=254, unique=True)), + ('enrollment', models.CharField(max_length=50, unique=True)), + ('age', models.IntegerField()), + ('gender', models.CharField(choices=[('Male', 'Male'), ('Female', 'Female')], max_length=10)), + ('department', models.CharField(max_length=100)), + ('semester', models.IntegerField()), + ('registration_date', models.DateTimeField(auto_now_add=True)), + ], + ), + ] diff --git a/registration/migrations/0002_registration_game.py b/registration/migrations/0002_registration_game.py new file mode 100644 index 0000000000000000000000000000000000000000..9c03df7ed40db62276b2b98275328f2729cd5e9b --- /dev/null +++ b/registration/migrations/0002_registration_game.py @@ -0,0 +1,19 @@ +# Generated by Django 5.1.4 on 2025-01-30 02:17 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='registration', + name='game', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, to='registration.game'), + ), + ] diff --git a/registration/migrations/0003_alter_game_gender.py b/registration/migrations/0003_alter_game_gender.py new file mode 100644 index 0000000000000000000000000000000000000000..25f400007b110628a63b2d2e4f7bb1749be99c2e --- /dev/null +++ b/registration/migrations/0003_alter_game_gender.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.3 on 2025-01-31 03:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration', '0002_registration_game'), + ] + + operations = [ + migrations.AlterField( + model_name='game', + name='gender', + field=models.CharField(choices=[('Male', 'Male'), ('Female', 'Female')], max_length=10), + ), + ] diff --git a/registration/migrations/0004_alter_registration_enrollment.py b/registration/migrations/0004_alter_registration_enrollment.py new file mode 100644 index 0000000000000000000000000000000000000000..094b26b922a5331489fcb3fdfc10b9f118064f24 --- /dev/null +++ b/registration/migrations/0004_alter_registration_enrollment.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.3 on 2025-01-31 09:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration', '0003_alter_game_gender'), + ] + + operations = [ + migrations.AlterField( + model_name='registration', + name='enrollment', + field=models.CharField(max_length=50), + ), + ] diff --git a/registration/migrations/0005_alter_registration_email.py b/registration/migrations/0005_alter_registration_email.py new file mode 100644 index 0000000000000000000000000000000000000000..6fe275e3202b858b758b4780a0656e808414e593 --- /dev/null +++ b/registration/migrations/0005_alter_registration_email.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.3 on 2025-01-31 10:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('registration', '0004_alter_registration_enrollment'), + ] + + operations = [ + migrations.AlterField( + model_name='registration', + name='email', + field=models.EmailField(max_length=254), + ), + ] diff --git a/registration/migrations/__init__.py b/registration/migrations/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/registration/migrations/__pycache__/0001_initial.cpython-310.pyc b/registration/migrations/__pycache__/0001_initial.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ec83785bc1c72fbd2e08312ecf2bbbe0c7658ec3 Binary files /dev/null and b/registration/migrations/__pycache__/0001_initial.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/0001_initial.cpython-311.pyc b/registration/migrations/__pycache__/0001_initial.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8a8bb99004a86101c0407f3e19114e57f9c3a000 Binary files /dev/null and b/registration/migrations/__pycache__/0001_initial.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/0001_initial.cpython-312.pyc b/registration/migrations/__pycache__/0001_initial.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a5bddd44889b946d6f923dd4400af22a9260f130 Binary files /dev/null and b/registration/migrations/__pycache__/0001_initial.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/0001_initial.cpython-313.pyc b/registration/migrations/__pycache__/0001_initial.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34c35359e0e987681ca353a037e0e22afc163728 Binary files /dev/null and b/registration/migrations/__pycache__/0001_initial.cpython-313.pyc differ diff --git a/registration/migrations/__pycache__/0002_registration_game.cpython-310.pyc b/registration/migrations/__pycache__/0002_registration_game.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b68bf9102e0f1fbb1a8d2d946f2f2187c22eb16b Binary files /dev/null and b/registration/migrations/__pycache__/0002_registration_game.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/0002_registration_game.cpython-311.pyc b/registration/migrations/__pycache__/0002_registration_game.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..42fdb457186ebaa96c4a63769ea8a0b7be5c196e Binary files /dev/null and b/registration/migrations/__pycache__/0002_registration_game.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/0002_registration_game.cpython-312.pyc b/registration/migrations/__pycache__/0002_registration_game.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..634276d11c37395c87fb5f98fd6278477e862476 Binary files /dev/null and b/registration/migrations/__pycache__/0002_registration_game.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/0002_registration_game.cpython-313.pyc b/registration/migrations/__pycache__/0002_registration_game.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bc5d3058294127afe0b3647462d03dbc0ad6b477 Binary files /dev/null and b/registration/migrations/__pycache__/0002_registration_game.cpython-313.pyc differ diff --git a/registration/migrations/__pycache__/0003_alter_game_gender.cpython-310.pyc b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0479360a235a8b11f263977a6b9a6d20b1100743 Binary files /dev/null and b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/0003_alter_game_gender.cpython-311.pyc b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0e7a092e12ccc13ff4230eb0c598a126a5089b91 Binary files /dev/null and b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/0003_alter_game_gender.cpython-312.pyc b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4ead54446bd58be87ac25fd83083ca806fa31ff3 Binary files /dev/null and b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/0003_alter_game_gender.cpython-313.pyc b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7c1df332bdfd681c3a56ee3579dba46ff277a2ec Binary files /dev/null and b/registration/migrations/__pycache__/0003_alter_game_gender.cpython-313.pyc differ diff --git a/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-310.pyc b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..caf2dfa0e28b10970a16ed6c55ea4d78d8e97be5 Binary files /dev/null and b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-311.pyc b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1501910aa7a8c96cdf25cfbc05df3396c81f2419 Binary files /dev/null and b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-312.pyc b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..967981bb6fe09d66557a8ced908b3ecd5c2ba35b Binary files /dev/null and b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-313.pyc b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4cc369515c697583dda806ffb4b6099e00232f24 Binary files /dev/null and b/registration/migrations/__pycache__/0004_alter_registration_enrollment.cpython-313.pyc differ diff --git a/registration/migrations/__pycache__/0005_alter_registration_email.cpython-310.pyc b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..331148b2267917068c6327155feeb943a105440a Binary files /dev/null and b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/0005_alter_registration_email.cpython-311.pyc b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..344aa1067dea081eab6638db9fb16e32655a9b1a Binary files /dev/null and b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/0005_alter_registration_email.cpython-312.pyc b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d3a344f3f71f2c838d6afb6dc29efb2733a64b45 Binary files /dev/null and b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/0005_alter_registration_email.cpython-313.pyc b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..9fbdd1c1cfd6f339446e298c0122abcbd347ef0d Binary files /dev/null and b/registration/migrations/__pycache__/0005_alter_registration_email.cpython-313.pyc differ diff --git a/registration/migrations/__pycache__/__init__.cpython-310.pyc b/registration/migrations/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b2a87ef5a98e1e54e9f6cebdca03879935051dec Binary files /dev/null and b/registration/migrations/__pycache__/__init__.cpython-310.pyc differ diff --git a/registration/migrations/__pycache__/__init__.cpython-311.pyc b/registration/migrations/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1fc768c1de797b0326c243a737f7dcb4700acb84 Binary files /dev/null and b/registration/migrations/__pycache__/__init__.cpython-311.pyc differ diff --git a/registration/migrations/__pycache__/__init__.cpython-312.pyc b/registration/migrations/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..97e18b41acef74f3ce0e75fcde1a49cdbd9ae7e4 Binary files /dev/null and b/registration/migrations/__pycache__/__init__.cpython-312.pyc differ diff --git a/registration/migrations/__pycache__/__init__.cpython-313.pyc b/registration/migrations/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b4010434c9e830ad778da239575a77aa28f80c7c Binary files /dev/null and b/registration/migrations/__pycache__/__init__.cpython-313.pyc differ diff --git a/registration/models.py b/registration/models.py new file mode 100644 index 0000000000000000000000000000000000000000..3818159fd32cd6e758bb5b00b79d5ec60e70cb4f --- /dev/null +++ b/registration/models.py @@ -0,0 +1,25 @@ +from django.db import models + +class Game(models.Model): + GENDER_CHOICES = [ + ('Male', 'Male'), + ('Female', 'Female'), + ] + name = models.CharField(max_length=100) + gender = models.CharField(max_length=10, choices=GENDER_CHOICES) + + def __str__(self): + return self.name + +class Registration(models.Model): + name = models.CharField(max_length=100) + email = models.EmailField() + enrollment = models.CharField(max_length=50) + age = models.IntegerField() + gender = models.CharField(max_length=10, choices=[('Male', 'Male'), ('Female', 'Female')]) + department = models.CharField(max_length=100) + semester = models.IntegerField() + registration_date = models.DateTimeField(auto_now_add=True) + game = models.ForeignKey(Game, on_delete=models.CASCADE, default=1) + def __str__(self): + return f"{self.name} - {self.game.name}" diff --git a/registration/tests.py b/registration/tests.py new file mode 100644 index 0000000000000000000000000000000000000000..de8bdc00eb2fed53494a534d48e400faa830dbd9 --- /dev/null +++ b/registration/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/registration/urls.py b/registration/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..81b466b4e76669022cd46cc4b6db4b341841688d --- /dev/null +++ b/registration/urls.py @@ -0,0 +1,9 @@ +from django.urls import path +from . import views + +urlpatterns = [ + path('get-games/', views.get_games, name='get_games'), + path('register//', views.register, name='register'), + path('get-filtered-registrations/', views.get_filtered_registrations, name='get_filtered_registrations'), + path('download-excel/', views.download_excel, name='download_excel'), +] diff --git a/registration/views.py b/registration/views.py new file mode 100644 index 0000000000000000000000000000000000000000..ba0b140f7ef15faca30883e15d5e77656a641d1c --- /dev/null +++ b/registration/views.py @@ -0,0 +1,150 @@ +from django.http import JsonResponse, HttpResponse +from django.views.decorators.csrf import csrf_exempt +from .models import Game, Registration +from django.db.models import Q +import json +import pandas as pd # Import pandas for Excel file creation +from django.utils import timezone + +@csrf_exempt +def get_games(request): + """ + API to fetch games based on gender, including common games. + """ + gender = request.GET.get('gender') # Get gender from query params + games = Game.objects.filter(Q(gender=gender) | Q(gender='common')).values('id', 'name') + return JsonResponse(list(games), safe=False) + +@csrf_exempt +def register(request, game_name): + """ + API to handle registration using game name and gender from form data. + """ + if request.method == 'POST': + try: + # Parse JSON data from the request body + data = json.loads(request.body) + gender = data.get('gender') # Get gender from the request body + + # Construct the full game name with gender suffix + full_game_name = f"{game_name}_{gender}" + + # Fetch the game by full name + game = Game.objects.get(name=full_game_name) + + # Create a new registration + registration = Registration.objects.create( + name=data.get('name'), + email=data.get('email'), + enrollment=data.get('enrollment'), + age=data.get('age'), + gender=gender, + department=data.get('department'), + semester=data.get('semester'), + game=game # Associate the registration with the selected game + ) + + # Return success response + return JsonResponse({ + 'status': 'success', + 'message': 'Registration successful!', + 'game': game.name, + 'gender': game.get_gender_display() + }, status=201) + + except Game.DoesNotExist: + return JsonResponse({ + 'status': 'error', + 'message': f'Game "{full_game_name}" not found!' + }, status=404) + + except Exception as e: + return JsonResponse({ + 'status': 'error', + 'message': str(e) + }, status=400) + + return JsonResponse({ + 'status': 'error', + 'message': 'Invalid request method. Only POST is allowed.' + }, status=405) + +@csrf_exempt +def get_filtered_registrations(request): + """ + API to fetch filtered registrations based on department, game, gender, and division. + """ + # Get filter parameters from the request + department = request.GET.get('department') + game_name = request.GET.get('game_name') # Changed from game_id to game_name + gender = request.GET.get('gender') + division = request.GET.get('division') # Add this field if needed + + # Build the query using Q objects + query = Q() + + if department: + query &= Q(department=department) + + if game_name: + # Check for both male and female versions of the game + game_name_male = f"{game_name}_Male" + game_name_female = f"{game_name}_Female" + query &= Q(game__name__in=[game_name_male, game_name_female]) + + if gender: + query &= Q(gender=gender) + + if division: + query &= Q(division=division) # Add this field if needed + + # Fetch filtered registrations + registrations = Registration.objects.filter(query).values( + 'name', 'email', 'enrollment', 'age', 'gender', 'department', 'semester', 'game__name', 'registration_date' + ) + + return JsonResponse(list(registrations), safe=False) + +def download_excel(request): + """ + API to download filtered registrations as an Excel file. + """ + # Get filter parameters from the request + department = request.GET.get('department') + game_name = request.GET.get('game_name') # Filter by game name + gender = request.GET.get('gender') + + # Build the query using Q objects + query = Q() + + if department: + query &= Q(department=department) + + if game_name: # Filter by game name + query &= Q(game__name__icontains=game_name) # case-insensitive match on game name + + if gender: + query &= Q(gender=gender) + + # Fetch filtered registrations + registrations = Registration.objects.filter(query).values( + 'name', 'email', 'enrollment', 'age', 'gender', 'department', 'semester', 'game__name', 'registration_date' + ) + + # Convert queryset to DataFrame + df = pd.DataFrame(list(registrations)) + + # Remove the registration date column + df = df.drop(columns=['registration_date']) + + # Replace game names (e.g., "football_Female" => "Football") + df['game__name'] = df['game__name'].str.replace('_', ' ').str.replace(r'(.*)(Male|Female)$', r'\1', regex=True).str.title() + + # Create Excel file in memory + excel_file = HttpResponse(content_type='application/vnd.ms-excel') + excel_file['Content-Disposition'] = 'attachment; filename=registrations.xlsx' + df.to_excel(excel_file, index=False) + + return excel_file + + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000000000000000000000000000000000000..6bb41ce8bf3b649a06e20db930ec61bc6d0b545b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,12 @@ +asgiref==3.8.1 +Django==5.1.6 +django-cors-headers==4.6.0 +numpy==2.2.2 +pandas==2.2.3 +psycopg==3.2.4 +psycopg2==2.9.10 +python-dateutil==2.9.0.post0 +pytz==2025.1 +six==1.17.0 +sqlparse==0.5.3 +tzdata==2025.1 diff --git a/sports_portal/__init__.py b/sports_portal/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/sports_portal/__pycache__/__init__.cpython-310.pyc b/sports_portal/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2c2bef450beaa091c9e69bd47e916c43fbf735ef Binary files /dev/null and b/sports_portal/__pycache__/__init__.cpython-310.pyc differ diff --git a/sports_portal/__pycache__/__init__.cpython-311.pyc b/sports_portal/__pycache__/__init__.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6b0aeb67fa4de5dfe6abfee0b5b5590c2fcedcc3 Binary files /dev/null and b/sports_portal/__pycache__/__init__.cpython-311.pyc differ diff --git a/sports_portal/__pycache__/__init__.cpython-312.pyc b/sports_portal/__pycache__/__init__.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3254839820de8dc28231ba257257a45e8b02ff3d Binary files /dev/null and b/sports_portal/__pycache__/__init__.cpython-312.pyc differ diff --git a/sports_portal/__pycache__/__init__.cpython-313.pyc b/sports_portal/__pycache__/__init__.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6aac92e398e751cc05c27a7ecbbf1ba18f89f58a Binary files /dev/null and b/sports_portal/__pycache__/__init__.cpython-313.pyc differ diff --git a/sports_portal/__pycache__/settings.cpython-310.pyc b/sports_portal/__pycache__/settings.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d72d75e6546df28a9868eb4fb3aeb135670127c9 Binary files /dev/null and b/sports_portal/__pycache__/settings.cpython-310.pyc differ diff --git a/sports_portal/__pycache__/settings.cpython-311.pyc b/sports_portal/__pycache__/settings.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..db602d89801d5cb9b985754b13f6bdc0316d3e07 Binary files /dev/null and b/sports_portal/__pycache__/settings.cpython-311.pyc differ diff --git a/sports_portal/__pycache__/settings.cpython-312.pyc b/sports_portal/__pycache__/settings.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..303f4dbb4280c29398c085b2a195cc758cda7554 Binary files /dev/null and b/sports_portal/__pycache__/settings.cpython-312.pyc differ diff --git a/sports_portal/__pycache__/settings.cpython-313.pyc b/sports_portal/__pycache__/settings.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c190ebda8865470d517713955828bd81805943f5 Binary files /dev/null and b/sports_portal/__pycache__/settings.cpython-313.pyc differ diff --git a/sports_portal/__pycache__/urls.cpython-310.pyc b/sports_portal/__pycache__/urls.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..580dfc5f765a6fb7d90c5bdfc4e752a8c5145f7a Binary files /dev/null and b/sports_portal/__pycache__/urls.cpython-310.pyc differ diff --git a/sports_portal/__pycache__/urls.cpython-311.pyc b/sports_portal/__pycache__/urls.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..49b8a4edf6cfc7d38ce0833016fb88b68b74188b Binary files /dev/null and b/sports_portal/__pycache__/urls.cpython-311.pyc differ diff --git a/sports_portal/__pycache__/urls.cpython-312.pyc b/sports_portal/__pycache__/urls.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1891bd73cc6d940152f2fb9830f7e5f730cd4ecd Binary files /dev/null and b/sports_portal/__pycache__/urls.cpython-312.pyc differ diff --git a/sports_portal/__pycache__/urls.cpython-313.pyc b/sports_portal/__pycache__/urls.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d4900ee18dcfdd486b07506469aedfa42988baac Binary files /dev/null and b/sports_portal/__pycache__/urls.cpython-313.pyc differ diff --git a/sports_portal/__pycache__/wsgi.cpython-310.pyc b/sports_portal/__pycache__/wsgi.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..52d34572b6184e8b634ce975b1600f659b004761 Binary files /dev/null and b/sports_portal/__pycache__/wsgi.cpython-310.pyc differ diff --git a/sports_portal/__pycache__/wsgi.cpython-311.pyc b/sports_portal/__pycache__/wsgi.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fea8c8345d1f21d56e02b37cdd4770b8725ee38b Binary files /dev/null and b/sports_portal/__pycache__/wsgi.cpython-311.pyc differ diff --git a/sports_portal/__pycache__/wsgi.cpython-312.pyc b/sports_portal/__pycache__/wsgi.cpython-312.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c678886c5d6a199722ad729582e111803bbd2aee Binary files /dev/null and b/sports_portal/__pycache__/wsgi.cpython-312.pyc differ diff --git a/sports_portal/__pycache__/wsgi.cpython-313.pyc b/sports_portal/__pycache__/wsgi.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..166665fad6915c4b310b33166a6d855ab9ffe6d9 Binary files /dev/null and b/sports_portal/__pycache__/wsgi.cpython-313.pyc differ diff --git a/sports_portal/asgi.py b/sports_portal/asgi.py new file mode 100644 index 0000000000000000000000000000000000000000..4fa2e86993fca1d891568a275a8a79d032a7b401 --- /dev/null +++ b/sports_portal/asgi.py @@ -0,0 +1,16 @@ +""" +ASGI config for sports_portal project. + +It exposes the ASGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/asgi/ +""" + +import os + +from django.core.asgi import get_asgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sports_portal.settings') + +application = get_asgi_application() diff --git a/sports_portal/settings.py b/sports_portal/settings.py new file mode 100644 index 0000000000000000000000000000000000000000..3caa70b54a940a48d7897f8c9d0c678d48f42aff --- /dev/null +++ b/sports_portal/settings.py @@ -0,0 +1,132 @@ +""" +Django settings for sports_portal project. + +Generated by 'django-admin startproject' using Django 5.1.4. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/topics/settings/ + +For the full list of settings and their values, see +https://docs.djangoproject.com/en/5.1/ref/settings/ +""" + +from pathlib import Path +import os +# Build paths inside the project like this: BASE_DIR / 'subdir'. +BASE_DIR = Path(__file__).resolve().parent.parent + + +# Quick-start development settings - unsuitable for production +# See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = 'django-insecure-p0!5q^nd$z&u9p7o54+d!umy*!6g@un_-ar)krfqu0^qcx#-dm' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True + +ALLOWED_HOSTS = [] + + +# Application definition + +INSTALLED_APPS = [ + 'django.contrib.admin', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'registration', + 'corsheaders', +] + +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'corsheaders.middleware.CorsMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] + +ROOT_URLCONF = 'sports_portal.urls' + +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.template.context_processors.debug', + 'django.template.context_processors.request', + 'django.contrib.auth.context_processors.auth', + 'django.contrib.messages.context_processors.messages', + ], + }, + }, +] + +WSGI_APPLICATION = 'sports_portal.wsgi.application' + + +# Database +# https://docs.djangoproject.com/en/5.1/ref/settings/#databases + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql', + 'NAME': 'postgres', # Your database name + 'USER': 'postgres.nycuaelqxozynmwfuitm', # Your PostgreSQL username + 'PASSWORD': os.environ.get("PASSWORD"), # Your PostgreSQL password + 'HOST': 'aws-0-ap-south-1.pooler.supabase.com', + 'PORT': '6543', + } +} + + +# Password validation +# https://docs.djangoproject.com/en/5.1/ref/settings/#auth-password-validators + +AUTH_PASSWORD_VALIDATORS = [ + { + 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + }, + { + 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + }, +] + + +# Internationalization +# https://docs.djangoproject.com/en/5.1/topics/i18n/ + +LANGUAGE_CODE = 'en-us' + +TIME_ZONE = 'UTC' + +USE_I18N = True + +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/5.1/howto/static-files/ + +STATIC_URL = 'static/' + +# Default primary key field type +# https://docs.djangoproject.com/en/5.1/ref/settings/#default-auto-field + +DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' +CORS_ALLOW_ALL_ORIGINS = True +CORS_ALLOW_METHODS = ["GET", "POST", "OPTIONS"] \ No newline at end of file diff --git a/sports_portal/urls.py b/sports_portal/urls.py new file mode 100644 index 0000000000000000000000000000000000000000..532251f94101a46020a79a9d8272c85593bf829f --- /dev/null +++ b/sports_portal/urls.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from django.urls import path, include + +urlpatterns = [ + path('admin/', admin.site.urls), + path('api/', include('registration.urls')), +] \ No newline at end of file diff --git a/sports_portal/wsgi.py b/sports_portal/wsgi.py new file mode 100644 index 0000000000000000000000000000000000000000..3d3b7e5668cc45f25a0ffb1a7d150959a0375361 --- /dev/null +++ b/sports_portal/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for sports_portal project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/5.1/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'sports_portal.settings') + +application = get_wsgi_application()