thejagstudio commited on
Commit
aff4b27
1 Parent(s): 59e97e0

Upload 50 files

Browse files
Files changed (50) hide show
  1. api/__init__.py +0 -0
  2. api/__pycache__/__init__.cpython-39.pyc +0 -0
  3. api/__pycache__/admin.cpython-39.pyc +0 -0
  4. api/__pycache__/apps.cpython-39.pyc +0 -0
  5. api/__pycache__/models.cpython-39.pyc +0 -0
  6. api/__pycache__/urls.cpython-39.pyc +0 -0
  7. api/__pycache__/views.cpython-39.pyc +0 -0
  8. api/admin.py +35 -0
  9. api/apps.py +6 -0
  10. api/migrations/0001_initial.py +382 -0
  11. api/migrations/0002_alter_bhagat_address_alter_bhagat_birthday_and_more.py +55 -0
  12. api/migrations/0003_alter_bhagat_address_alter_bhagat_birthday_and_more.py +37 -0
  13. api/migrations/0004_alter_bhajancategory_svg.py +17 -0
  14. api/migrations/0005_remove_bhajan_lyrics_en_url_and_more.py +48 -0
  15. api/migrations/0006_bhajan_isaudio_bhajan_iseng_bhajan_isger_and_more.py +32 -0
  16. api/migrations/0007_remove_bhajancategory_svg.py +16 -0
  17. api/migrations/0008_bhajan_bhajanid.py +17 -0
  18. api/migrations/0009_event_color_alter_event_created_by_and_more.py +52 -0
  19. api/migrations/0010_event_time.py +17 -0
  20. api/migrations/__init__.py +0 -0
  21. api/migrations/__pycache__/0001_initial.cpython-39.pyc +0 -0
  22. api/migrations/__pycache__/0002_alter_bhagat_address_alter_bhagat_birthday_and_more.cpython-39.pyc +0 -0
  23. api/migrations/__pycache__/0003_alter_bhagat_address_alter_bhagat_birthday_and_more.cpython-39.pyc +0 -0
  24. api/migrations/__pycache__/0004_alter_bhajancategory_svg.cpython-39.pyc +0 -0
  25. api/migrations/__pycache__/0005_remove_bhajan_lyrics_en_url_and_more.cpython-39.pyc +0 -0
  26. api/migrations/__pycache__/0006_bhajan_isaudio_bhajan_iseng_bhajan_isger_and_more.cpython-39.pyc +0 -0
  27. api/migrations/__pycache__/0007_remove_bhajancategory_svg.cpython-39.pyc +0 -0
  28. api/migrations/__pycache__/0008_bhajan_bhajanid.cpython-39.pyc +0 -0
  29. api/migrations/__pycache__/0009_event_color_alter_event_created_by_and_more.cpython-39.pyc +0 -0
  30. api/migrations/__pycache__/0010_event_time.cpython-39.pyc +0 -0
  31. api/migrations/__pycache__/__init__.cpython-39.pyc +0 -0
  32. api/models.py +115 -0
  33. api/tests.py +3 -0
  34. api/urls.py +17 -0
  35. api/views.py +206 -0
  36. db.sqlite3 +0 -0
  37. extra/bhajanData.json +0 -0
  38. extra/bhajanEntry.txt +16 -0
  39. hsapssconnect/__init__.py +0 -0
  40. hsapssconnect/__pycache__/__init__.cpython-311.pyc +0 -0
  41. hsapssconnect/__pycache__/__init__.cpython-39.pyc +0 -0
  42. hsapssconnect/__pycache__/settings.cpython-311.pyc +0 -0
  43. hsapssconnect/__pycache__/settings.cpython-39.pyc +0 -0
  44. hsapssconnect/__pycache__/urls.cpython-39.pyc +0 -0
  45. hsapssconnect/__pycache__/wsgi.cpython-39.pyc +0 -0
  46. hsapssconnect/asgi.py +16 -0
  47. hsapssconnect/settings.py +135 -0
  48. hsapssconnect/urls.py +8 -0
  49. hsapssconnect/wsgi.py +16 -0
  50. manage.py +22 -0
api/__init__.py ADDED
File without changes
api/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (146 Bytes). View file
 
api/__pycache__/admin.cpython-39.pyc ADDED
Binary file (1.64 kB). View file
 
api/__pycache__/apps.cpython-39.pyc ADDED
Binary file (417 Bytes). View file
 
api/__pycache__/models.cpython-39.pyc ADDED
Binary file (5.29 kB). View file
 
api/__pycache__/urls.cpython-39.pyc ADDED
Binary file (845 Bytes). View file
 
api/__pycache__/views.cpython-39.pyc ADDED
Binary file (5.76 kB). View file
 
api/admin.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.contrib import admin
2
+ from .models import Bhagat, Event, Attendance, Message, Notification, Region, BhajanCategory, Bhajan
3
+ from import_export.admin import ImportExportModelAdmin
4
+
5
+ # Register your models here.
6
+ class BhagatAdmin(ImportExportModelAdmin):
7
+ list_display = ('__str__', 'email', 'region', 'user_type', 'assigned_to')
8
+ list_filter = ('region', 'user_type')
9
+ search_fields = ('__str__', 'email', 'region', 'user_type', 'assigned_to')
10
+
11
+ class RegionAdmin(ImportExportModelAdmin):
12
+ list_display = ('name',)
13
+
14
+ class BhajanCategoryAdmin(ImportExportModelAdmin):
15
+ list_display = ('name', 'link')
16
+ search_fields = ('name',)
17
+
18
+ class BhajanAdmin(ImportExportModelAdmin):
19
+ list_display = ('title', 'title_guj', 'category', 'lyricsBtn')
20
+ search_fields = ('title', 'title_guj', 'category')
21
+ list_filter = ('category',)
22
+ # 'musicPreivew',
23
+
24
+ class EventAdmin(ImportExportModelAdmin):
25
+ list_display = ('title', 'date', 'region', 'is_approved', 'color')
26
+ list_filter = ('region', 'is_approved', 'color')
27
+ search_fields = ('title', 'date', 'region', 'is_approved', 'color')
28
+ list_editable = ('is_approved', 'color')
29
+
30
+ admin.site.register(Bhagat, BhagatAdmin)
31
+ admin.site.register(Region, RegionAdmin)
32
+ admin.site.register(BhajanCategory, BhajanCategoryAdmin)
33
+ admin.site.register(Bhajan, BhajanAdmin)
34
+ admin.site.register(Event, EventAdmin)
35
+
api/apps.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class ApiConfig(AppConfig):
5
+ default_auto_field = "django.db.models.BigAutoField"
6
+ name = "api"
api/migrations/0001_initial.py ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 15:27
2
+
3
+ from django.conf import settings
4
+ import django.contrib.auth.models
5
+ import django.contrib.auth.validators
6
+ from django.db import migrations, models
7
+ import django.db.models.deletion
8
+ import django.utils.timezone
9
+
10
+
11
+ class Migration(migrations.Migration):
12
+ initial = True
13
+
14
+ dependencies = [
15
+ ("auth", "0012_alter_user_first_name_max_length"),
16
+ ]
17
+
18
+ operations = [
19
+ migrations.CreateModel(
20
+ name="Bhagat",
21
+ fields=[
22
+ (
23
+ "id",
24
+ models.BigAutoField(
25
+ auto_created=True,
26
+ primary_key=True,
27
+ serialize=False,
28
+ verbose_name="ID",
29
+ ),
30
+ ),
31
+ ("password", models.CharField(max_length=128, verbose_name="password")),
32
+ (
33
+ "last_login",
34
+ models.DateTimeField(
35
+ blank=True, null=True, verbose_name="last login"
36
+ ),
37
+ ),
38
+ (
39
+ "is_superuser",
40
+ models.BooleanField(
41
+ default=False,
42
+ help_text="Designates that this user has all permissions without explicitly assigning them.",
43
+ verbose_name="superuser status",
44
+ ),
45
+ ),
46
+ (
47
+ "username",
48
+ models.CharField(
49
+ error_messages={
50
+ "unique": "A user with that username already exists."
51
+ },
52
+ help_text="Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.",
53
+ max_length=150,
54
+ unique=True,
55
+ validators=[
56
+ django.contrib.auth.validators.UnicodeUsernameValidator()
57
+ ],
58
+ verbose_name="username",
59
+ ),
60
+ ),
61
+ (
62
+ "first_name",
63
+ models.CharField(
64
+ blank=True, max_length=150, verbose_name="first name"
65
+ ),
66
+ ),
67
+ (
68
+ "last_name",
69
+ models.CharField(
70
+ blank=True, max_length=150, verbose_name="last name"
71
+ ),
72
+ ),
73
+ (
74
+ "email",
75
+ models.EmailField(
76
+ blank=True, max_length=254, verbose_name="email address"
77
+ ),
78
+ ),
79
+ (
80
+ "is_staff",
81
+ models.BooleanField(
82
+ default=False,
83
+ help_text="Designates whether the user can log into this admin site.",
84
+ verbose_name="staff status",
85
+ ),
86
+ ),
87
+ (
88
+ "is_active",
89
+ models.BooleanField(
90
+ default=True,
91
+ help_text="Designates whether this user should be treated as active. Unselect this instead of deleting accounts.",
92
+ verbose_name="active",
93
+ ),
94
+ ),
95
+ (
96
+ "date_joined",
97
+ models.DateTimeField(
98
+ default=django.utils.timezone.now, verbose_name="date joined"
99
+ ),
100
+ ),
101
+ (
102
+ "user_type",
103
+ models.CharField(
104
+ choices=[
105
+ ("superadmin", "Super Admin"),
106
+ ("regionadmin", "Region Admin"),
107
+ ("monitor", "Monitor"),
108
+ ("user", "User"),
109
+ ],
110
+ max_length=20,
111
+ ),
112
+ ),
113
+ ("phone", models.CharField(max_length=15)),
114
+ (
115
+ "member_type",
116
+ models.CharField(
117
+ choices=[
118
+ ("ambrish", "Ambrish"),
119
+ ("sadbhav", "Sadbhav"),
120
+ ("vip", "VIP"),
121
+ ("youvak", "Youvak"),
122
+ ],
123
+ max_length=20,
124
+ ),
125
+ ),
126
+ ("birthday", models.DateField()),
127
+ ("address", models.TextField()),
128
+ (
129
+ "assigned_to",
130
+ models.ForeignKey(
131
+ blank=True,
132
+ null=True,
133
+ on_delete=django.db.models.deletion.SET_NULL,
134
+ related_name="assigned_users",
135
+ to=settings.AUTH_USER_MODEL,
136
+ ),
137
+ ),
138
+ (
139
+ "groups",
140
+ models.ManyToManyField(
141
+ blank=True,
142
+ help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
143
+ related_name="user_set",
144
+ related_query_name="user",
145
+ to="auth.group",
146
+ verbose_name="groups",
147
+ ),
148
+ ),
149
+ ],
150
+ options={
151
+ "verbose_name": "user",
152
+ "verbose_name_plural": "users",
153
+ "abstract": False,
154
+ },
155
+ managers=[
156
+ ("objects", django.contrib.auth.models.UserManager()),
157
+ ],
158
+ ),
159
+ migrations.CreateModel(
160
+ name="BhajanCategory",
161
+ fields=[
162
+ (
163
+ "id",
164
+ models.BigAutoField(
165
+ auto_created=True,
166
+ primary_key=True,
167
+ serialize=False,
168
+ verbose_name="ID",
169
+ ),
170
+ ),
171
+ ("name", models.CharField(max_length=100)),
172
+ ("svg", models.TextField()),
173
+ ("link", models.CharField(max_length=100)),
174
+ ],
175
+ ),
176
+ migrations.CreateModel(
177
+ name="Region",
178
+ fields=[
179
+ (
180
+ "id",
181
+ models.BigAutoField(
182
+ auto_created=True,
183
+ primary_key=True,
184
+ serialize=False,
185
+ verbose_name="ID",
186
+ ),
187
+ ),
188
+ ("name", models.CharField(max_length=100)),
189
+ ],
190
+ ),
191
+ migrations.CreateModel(
192
+ name="Notification",
193
+ fields=[
194
+ (
195
+ "id",
196
+ models.BigAutoField(
197
+ auto_created=True,
198
+ primary_key=True,
199
+ serialize=False,
200
+ verbose_name="ID",
201
+ ),
202
+ ),
203
+ ("content", models.TextField()),
204
+ ("timestamp", models.DateTimeField(auto_now_add=True)),
205
+ (
206
+ "notification_type",
207
+ models.CharField(
208
+ choices=[
209
+ ("event", "Event"),
210
+ ("birthday", "Birthday"),
211
+ ("custom", "Custom"),
212
+ ],
213
+ max_length=20,
214
+ ),
215
+ ),
216
+ (
217
+ "recipients",
218
+ models.ManyToManyField(
219
+ related_name="received_notifications",
220
+ to=settings.AUTH_USER_MODEL,
221
+ ),
222
+ ),
223
+ (
224
+ "sender",
225
+ models.ForeignKey(
226
+ on_delete=django.db.models.deletion.CASCADE,
227
+ related_name="sent_notifications",
228
+ to=settings.AUTH_USER_MODEL,
229
+ ),
230
+ ),
231
+ ],
232
+ ),
233
+ migrations.CreateModel(
234
+ name="Message",
235
+ fields=[
236
+ (
237
+ "id",
238
+ models.BigAutoField(
239
+ auto_created=True,
240
+ primary_key=True,
241
+ serialize=False,
242
+ verbose_name="ID",
243
+ ),
244
+ ),
245
+ ("content", models.TextField()),
246
+ ("timestamp", models.DateTimeField(auto_now_add=True)),
247
+ (
248
+ "recipient",
249
+ models.ForeignKey(
250
+ on_delete=django.db.models.deletion.CASCADE,
251
+ related_name="received_messages",
252
+ to=settings.AUTH_USER_MODEL,
253
+ ),
254
+ ),
255
+ (
256
+ "sender",
257
+ models.ForeignKey(
258
+ on_delete=django.db.models.deletion.CASCADE,
259
+ related_name="sent_messages",
260
+ to=settings.AUTH_USER_MODEL,
261
+ ),
262
+ ),
263
+ ],
264
+ ),
265
+ migrations.CreateModel(
266
+ name="Event",
267
+ fields=[
268
+ (
269
+ "id",
270
+ models.BigAutoField(
271
+ auto_created=True,
272
+ primary_key=True,
273
+ serialize=False,
274
+ verbose_name="ID",
275
+ ),
276
+ ),
277
+ ("title", models.CharField(max_length=200)),
278
+ ("description", models.TextField()),
279
+ ("date", models.DateTimeField()),
280
+ ("is_approved", models.BooleanField(default=False)),
281
+ (
282
+ "created_by",
283
+ models.ForeignKey(
284
+ on_delete=django.db.models.deletion.CASCADE,
285
+ related_name="created_events",
286
+ to=settings.AUTH_USER_MODEL,
287
+ ),
288
+ ),
289
+ (
290
+ "region",
291
+ models.ForeignKey(
292
+ on_delete=django.db.models.deletion.CASCADE, to="api.region"
293
+ ),
294
+ ),
295
+ ],
296
+ ),
297
+ migrations.CreateModel(
298
+ name="Bhajan",
299
+ fields=[
300
+ (
301
+ "id",
302
+ models.BigAutoField(
303
+ auto_created=True,
304
+ primary_key=True,
305
+ serialize=False,
306
+ verbose_name="ID",
307
+ ),
308
+ ),
309
+ ("title", models.CharField(max_length=500)),
310
+ ("title_guj", models.CharField(max_length=500)),
311
+ ("lyrics_guj_url", models.URLField()),
312
+ ("lyrics_hi_url", models.URLField()),
313
+ ("lyrics_en_url", models.URLField()),
314
+ ("lyrics_ge_url", models.URLField()),
315
+ ("audio_url", models.URLField()),
316
+ (
317
+ "category",
318
+ models.ForeignKey(
319
+ on_delete=django.db.models.deletion.CASCADE,
320
+ to="api.bhajancategory",
321
+ ),
322
+ ),
323
+ ],
324
+ ),
325
+ migrations.CreateModel(
326
+ name="Attendance",
327
+ fields=[
328
+ (
329
+ "id",
330
+ models.BigAutoField(
331
+ auto_created=True,
332
+ primary_key=True,
333
+ serialize=False,
334
+ verbose_name="ID",
335
+ ),
336
+ ),
337
+ (
338
+ "status",
339
+ models.CharField(
340
+ choices=[
341
+ ("attending", "Attending"),
342
+ ("not_attending", "Not Attending"),
343
+ ("maybe", "Maybe"),
344
+ ],
345
+ max_length=20,
346
+ ),
347
+ ),
348
+ (
349
+ "event",
350
+ models.ForeignKey(
351
+ on_delete=django.db.models.deletion.CASCADE, to="api.event"
352
+ ),
353
+ ),
354
+ (
355
+ "user",
356
+ models.ForeignKey(
357
+ on_delete=django.db.models.deletion.CASCADE,
358
+ to=settings.AUTH_USER_MODEL,
359
+ ),
360
+ ),
361
+ ],
362
+ ),
363
+ migrations.AddField(
364
+ model_name="bhagat",
365
+ name="region",
366
+ field=models.ForeignKey(
367
+ null=True, on_delete=django.db.models.deletion.SET_NULL, to="api.region"
368
+ ),
369
+ ),
370
+ migrations.AddField(
371
+ model_name="bhagat",
372
+ name="user_permissions",
373
+ field=models.ManyToManyField(
374
+ blank=True,
375
+ help_text="Specific permissions for this user.",
376
+ related_name="user_set",
377
+ related_query_name="user",
378
+ to="auth.permission",
379
+ verbose_name="user permissions",
380
+ ),
381
+ ),
382
+ ]
api/migrations/0002_alter_bhagat_address_alter_bhagat_birthday_and_more.py ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 15:30
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0001_initial"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AlterField(
13
+ model_name="bhagat",
14
+ name="address",
15
+ field=models.TextField(default=None, null=True),
16
+ ),
17
+ migrations.AlterField(
18
+ model_name="bhagat",
19
+ name="birthday",
20
+ field=models.DateField(default=None, null=True),
21
+ ),
22
+ migrations.AlterField(
23
+ model_name="bhagat",
24
+ name="member_type",
25
+ field=models.CharField(
26
+ choices=[
27
+ ("ambrish", "Ambrish"),
28
+ ("sadbhav", "Sadbhav"),
29
+ ("vip", "VIP"),
30
+ ("youvak", "Youvak"),
31
+ ],
32
+ max_length=20,
33
+ null="youvak",
34
+ ),
35
+ ),
36
+ migrations.AlterField(
37
+ model_name="bhagat",
38
+ name="phone",
39
+ field=models.CharField(max_length=15, null=True),
40
+ ),
41
+ migrations.AlterField(
42
+ model_name="bhagat",
43
+ name="user_type",
44
+ field=models.CharField(
45
+ choices=[
46
+ ("superadmin", "Super Admin"),
47
+ ("regionadmin", "Region Admin"),
48
+ ("monitor", "Monitor"),
49
+ ("user", "User"),
50
+ ],
51
+ default="user",
52
+ max_length=20,
53
+ ),
54
+ ),
55
+ ]
api/migrations/0003_alter_bhagat_address_alter_bhagat_birthday_and_more.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 15:33
2
+
3
+ import datetime
4
+ from django.db import migrations, models
5
+
6
+
7
+ class Migration(migrations.Migration):
8
+ dependencies = [
9
+ ("api", "0002_alter_bhagat_address_alter_bhagat_birthday_and_more"),
10
+ ]
11
+
12
+ operations = [
13
+ migrations.AlterField(
14
+ model_name="bhagat",
15
+ name="address",
16
+ field=models.TextField(null=True),
17
+ ),
18
+ migrations.AlterField(
19
+ model_name="bhagat",
20
+ name="birthday",
21
+ field=models.DateField(default=datetime.date.today, null=True),
22
+ ),
23
+ migrations.AlterField(
24
+ model_name="bhagat",
25
+ name="member_type",
26
+ field=models.CharField(
27
+ choices=[
28
+ ("ambrish", "Ambrish"),
29
+ ("sadbhav", "Sadbhav"),
30
+ ("vip", "VIP"),
31
+ ("youvak", "Youvak"),
32
+ ],
33
+ default="youvak",
34
+ max_length=20,
35
+ ),
36
+ ),
37
+ ]
api/migrations/0004_alter_bhajancategory_svg.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 15:51
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0003_alter_bhagat_address_alter_bhagat_birthday_and_more"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AlterField(
13
+ model_name="bhajancategory",
14
+ name="svg",
15
+ field=models.TextField(blank=True),
16
+ ),
17
+ ]
api/migrations/0005_remove_bhajan_lyrics_en_url_and_more.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 16:31
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0004_alter_bhajancategory_svg"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.RemoveField(
13
+ model_name="bhajan",
14
+ name="lyrics_en_url",
15
+ ),
16
+ migrations.RemoveField(
17
+ model_name="bhajan",
18
+ name="lyrics_ge_url",
19
+ ),
20
+ migrations.RemoveField(
21
+ model_name="bhajan",
22
+ name="lyrics_guj_url",
23
+ ),
24
+ migrations.RemoveField(
25
+ model_name="bhajan",
26
+ name="lyrics_hi_url",
27
+ ),
28
+ migrations.AddField(
29
+ model_name="bhajan",
30
+ name="lyrics",
31
+ field=models.CharField(blank=True, max_length=50),
32
+ ),
33
+ migrations.AlterField(
34
+ model_name="bhajan",
35
+ name="audio_url",
36
+ field=models.URLField(blank=True),
37
+ ),
38
+ migrations.AlterField(
39
+ model_name="bhajan",
40
+ name="title",
41
+ field=models.CharField(blank=True, max_length=500),
42
+ ),
43
+ migrations.AlterField(
44
+ model_name="bhajan",
45
+ name="title_guj",
46
+ field=models.CharField(blank=True, max_length=500),
47
+ ),
48
+ ]
api/migrations/0006_bhajan_isaudio_bhajan_iseng_bhajan_isger_and_more.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-22 16:37
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0005_remove_bhajan_lyrics_en_url_and_more"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AddField(
13
+ model_name="bhajan",
14
+ name="isAudio",
15
+ field=models.BooleanField(default=False),
16
+ ),
17
+ migrations.AddField(
18
+ model_name="bhajan",
19
+ name="isEng",
20
+ field=models.BooleanField(default=False),
21
+ ),
22
+ migrations.AddField(
23
+ model_name="bhajan",
24
+ name="isGer",
25
+ field=models.BooleanField(default=False),
26
+ ),
27
+ migrations.AddField(
28
+ model_name="bhajan",
29
+ name="isHnd",
30
+ field=models.BooleanField(default=False),
31
+ ),
32
+ ]
api/migrations/0007_remove_bhajancategory_svg.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-23 15:03
2
+
3
+ from django.db import migrations
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0006_bhajan_isaudio_bhajan_iseng_bhajan_isger_and_more"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.RemoveField(
13
+ model_name="bhajancategory",
14
+ name="svg",
15
+ ),
16
+ ]
api/migrations/0008_bhajan_bhajanid.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-23 15:37
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0007_remove_bhajancategory_svg"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AddField(
13
+ model_name="bhajan",
14
+ name="bhajanId",
15
+ field=models.IntegerField(blank=True, default=0),
16
+ ),
17
+ ]
api/migrations/0009_event_color_alter_event_created_by_and_more.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-24 00:35
2
+
3
+ from django.conf import settings
4
+ from django.db import migrations, models
5
+ import django.db.models.deletion
6
+
7
+
8
+ class Migration(migrations.Migration):
9
+ dependencies = [
10
+ ("api", "0008_bhajan_bhajanid"),
11
+ ]
12
+
13
+ operations = [
14
+ migrations.AddField(
15
+ model_name="event",
16
+ name="color",
17
+ field=models.CharField(
18
+ choices=[
19
+ ("orange", "Shabha"),
20
+ ("green", "Activity"),
21
+ ("blue", "Birthday"),
22
+ ("red", "Important"),
23
+ ("purple", "Gathering"),
24
+ ("yellow", "Festival"),
25
+ ("pink", "Special"),
26
+ ],
27
+ default="orange",
28
+ max_length=15,
29
+ ),
30
+ ),
31
+ migrations.AlterField(
32
+ model_name="event",
33
+ name="created_by",
34
+ field=models.ForeignKey(
35
+ blank=True,
36
+ null=True,
37
+ on_delete=django.db.models.deletion.CASCADE,
38
+ related_name="created_events",
39
+ to=settings.AUTH_USER_MODEL,
40
+ ),
41
+ ),
42
+ migrations.AlterField(
43
+ model_name="event",
44
+ name="region",
45
+ field=models.ForeignKey(
46
+ blank=True,
47
+ null=True,
48
+ on_delete=django.db.models.deletion.CASCADE,
49
+ to="api.region",
50
+ ),
51
+ ),
52
+ ]
api/migrations/0010_event_time.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated by Django 4.2.16 on 2024-09-24 00:41
2
+
3
+ from django.db import migrations, models
4
+
5
+
6
+ class Migration(migrations.Migration):
7
+ dependencies = [
8
+ ("api", "0009_event_color_alter_event_created_by_and_more"),
9
+ ]
10
+
11
+ operations = [
12
+ migrations.AddField(
13
+ model_name="event",
14
+ name="time",
15
+ field=models.TimeField(default="00:00"),
16
+ ),
17
+ ]
api/migrations/__init__.py ADDED
File without changes
api/migrations/__pycache__/0001_initial.cpython-39.pyc ADDED
Binary file (4.99 kB). View file
 
api/migrations/__pycache__/0002_alter_bhagat_address_alter_bhagat_birthday_and_more.cpython-39.pyc ADDED
Binary file (1.08 kB). View file
 
api/migrations/__pycache__/0003_alter_bhagat_address_alter_bhagat_birthday_and_more.cpython-39.pyc ADDED
Binary file (944 Bytes). View file
 
api/migrations/__pycache__/0004_alter_bhajancategory_svg.cpython-39.pyc ADDED
Binary file (627 Bytes). View file
 
api/migrations/__pycache__/0005_remove_bhajan_lyrics_en_url_and_more.cpython-39.pyc ADDED
Binary file (953 Bytes). View file
 
api/migrations/__pycache__/0006_bhajan_isaudio_bhajan_iseng_bhajan_isger_and_more.cpython-39.pyc ADDED
Binary file (753 Bytes). View file
 
api/migrations/__pycache__/0007_remove_bhajancategory_svg.cpython-39.pyc ADDED
Binary file (565 Bytes). View file
 
api/migrations/__pycache__/0008_bhajan_bhajanid.cpython-39.pyc ADDED
Binary file (606 Bytes). View file
 
api/migrations/__pycache__/0009_event_color_alter_event_created_by_and_more.cpython-39.pyc ADDED
Binary file (1.18 kB). View file
 
api/migrations/__pycache__/0010_event_time.cpython-39.pyc ADDED
Binary file (603 Bytes). View file
 
api/migrations/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (157 Bytes). View file
 
api/models.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.db import models
2
+ from django.contrib.auth.models import AbstractUser
3
+ import datetime as DateTime
4
+ from django.utils.html import mark_safe
5
+
6
+ class Bhagat(AbstractUser):
7
+ USER_TYPES = (
8
+ ('superadmin', 'Super Admin'),
9
+ ('regionadmin', 'Region Admin'),
10
+ ('monitor', 'Monitor'),
11
+ ('user', 'User'),
12
+ )
13
+ MEMBER_TYPES = (
14
+ ('ambrish', 'Ambrish'),
15
+ ('sadbhav', 'Sadbhav'),
16
+ ('vip', 'VIP'),
17
+ ('youvak', 'Youvak'),
18
+ )
19
+ user_type = models.CharField(max_length=20, choices=USER_TYPES, default="user")
20
+ phone = models.CharField(max_length=15, null=True)
21
+ member_type = models.CharField(max_length=20, choices=MEMBER_TYPES, default="youvak")
22
+ region = models.ForeignKey('Region', on_delete=models.SET_NULL, null=True)
23
+ birthday = models.DateField(default=DateTime.date.today, null=True)
24
+ address = models.TextField(null=True)
25
+ assigned_to = models.ForeignKey('self', on_delete=models.SET_NULL, null=True, blank=True, related_name='assigned_users')
26
+
27
+ def __str__(self):
28
+ return self.first_name + ' ' + self.last_name
29
+
30
+
31
+ class Region(models.Model):
32
+ name = models.CharField(max_length=100)
33
+
34
+ def __str__(self):
35
+ return self.name
36
+
37
+
38
+ class Event(models.Model):
39
+ COLOR_CHOICES = (("orange","Shabha"), ("green","Activity"), ("blue","Birthday"), ("red","Important"), ("purple","Gathering"), ("yellow","Festival"), ("pink","Special"))
40
+ title = models.CharField(max_length=200)
41
+ description = models.TextField()
42
+ date = models.DateTimeField()
43
+ time = models.TimeField(default='00:00')
44
+ created_by = models.ForeignKey(Bhagat, on_delete=models.CASCADE, related_name='created_events',blank=True,null=True)
45
+ region = models.ForeignKey(Region, on_delete=models.CASCADE, blank=True,null=True)
46
+ is_approved = models.BooleanField(default=False)
47
+ color = models.CharField(max_length=15, default='orange',choices=COLOR_CHOICES)
48
+
49
+ def __str__(self):
50
+ return self.title
51
+
52
+
53
+ class Attendance(models.Model):
54
+ user = models.ForeignKey(Bhagat, on_delete=models.CASCADE)
55
+ event = models.ForeignKey(Event, on_delete=models.CASCADE)
56
+ status = models.CharField(max_length=20, choices=(('attending', 'Attending'), ('not_attending', 'Not Attending'), ('maybe', 'Maybe')))
57
+
58
+
59
+ class Message(models.Model):
60
+ sender = models.ForeignKey(Bhagat, on_delete=models.CASCADE, related_name='sent_messages')
61
+ recipient = models.ForeignKey(Bhagat, on_delete=models.CASCADE, related_name='received_messages')
62
+ content = models.TextField()
63
+ timestamp = models.DateTimeField(auto_now_add=True)
64
+
65
+
66
+ class Notification(models.Model):
67
+ sender = models.ForeignKey(Bhagat, on_delete=models.CASCADE, related_name='sent_notifications')
68
+ recipients = models.ManyToManyField(Bhagat, related_name='received_notifications')
69
+ content = models.TextField()
70
+ timestamp = models.DateTimeField(auto_now_add=True)
71
+ notification_type = models.CharField(max_length=20, choices=(('event', 'Event'), ('birthday', 'Birthday'), ('custom', 'Custom')))
72
+
73
+ class BhajanCategory(models.Model):
74
+ name = models.CharField(max_length=100)
75
+ link = models.CharField(max_length=100)
76
+
77
+ def __str__(self):
78
+ return self.name
79
+
80
+ class Bhajan(models.Model):
81
+ bhajanId = models.IntegerField(blank=True,default=0)
82
+ title = models.CharField(max_length=500,blank=True)
83
+ title_guj = models.CharField(max_length=500,blank=True)
84
+ category = models.ForeignKey(BhajanCategory, on_delete=models.CASCADE)
85
+ lyrics = models.CharField(max_length=50, blank=True)
86
+ audio_url = models.URLField(blank=True)
87
+ isEng = models.BooleanField(default=False)
88
+ isHnd = models.BooleanField(default=False)
89
+ isGer = models.BooleanField(default=False)
90
+ isAudio = models.BooleanField(default=False)
91
+
92
+
93
+ def __str__(self):
94
+ return self.title
95
+
96
+ def musicPreivew(self):
97
+ if self.isAudio:
98
+ return mark_safe('<audio controls><source src="https://huggingface.co/spaces/thejagstudio/MusicStore/resolve/main/Bhajan Audio/%s" type="audio/mpeg"></audio>' % self.audio_url)
99
+ else:
100
+ return 'No Audio Available'
101
+
102
+ def lyricsBtn(self):
103
+ # i have four languages in my bhajan so add them all as buttons and show them on click
104
+ languages = [["","GUJ"]]
105
+ if self.isEng:
106
+ languages.append(['E','ENG'])
107
+ if self.isHnd:
108
+ languages.append(['H','HND'])
109
+ if self.isGer:
110
+ languages.append(['G','GER'])
111
+ html = '<ul class="object-tools" style="margin-top:0">'
112
+ for lang in languages:
113
+ html += '<li style="padding-bottom:12px"><a href="https://huggingface.co/spaces/thejagstudio/MusicStore/raw/main/HTML Files/'+lang[0] + self.lyrics+'" target="_blank" class="import_link">'+(lang[1])+'</a></li>'
114
+ html += '</ul>'
115
+ return mark_safe(html)
api/tests.py ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ from django.test import TestCase
2
+
3
+ # Create your tests here.
api/urls.py ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.urls import path
2
+ from . import views
3
+
4
+ urlpatterns = [
5
+ path('', views.dashboard, name='dashboard'),
6
+ path('dataEntry/', views.dataEntry, name='dataEntry'),
7
+ path('manage-users/', views.manage_users, name='manage_users'),
8
+ path('create-event/', views.create_event, name='create_event'),
9
+ path('approve-event/<int:event_id>/', views.approve_event, name='approve_event'),
10
+ path('update-attendance/<int:event_id>/', views.update_attendance, name='update_attendance'),
11
+ path('send-message/', views.send_message, name='send_message'),
12
+ path('send-notification/', views.send_notification, name='send_notification'),
13
+
14
+ path('bhajan-category-list/', views.bhajanCategoryList, name='bhajanCategoryList'),
15
+ path('bhajan-detail/<int:id>', views.bhajanDetail, name='bhajanDetail'),
16
+ path('event-list/', views.eventList, name='eventList'),
17
+ ]
api/views.py ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from django.shortcuts import render, get_object_or_404, redirect
2
+ from django.contrib.auth.decorators import login_required, user_passes_test
3
+ from django.http import JsonResponse, HttpResponse
4
+ from .models import Bhagat, Event, Attendance, Message, Notification
5
+ from django.views.decorators.http import require_POST
6
+ from django.utils import timezone
7
+ import json
8
+ from .models import Bhagat, Event, Attendance, Message, Notification, Region, BhajanCategory, Bhajan
9
+
10
+
11
+ def is_superadmin(user):
12
+ return user.user_type == 'superadmin'
13
+
14
+
15
+ def is_regionadmin(user):
16
+ return user.user_type == 'regionadmin'
17
+
18
+
19
+ def is_monitor(user):
20
+ return user.user_type == 'monitor'
21
+
22
+ def dataEntry(request):
23
+ # with open("./api/bhajanData.json", "r",encoding="utf-8") as f:
24
+ # data = json.load(f)["Prasang"]
25
+ # for bhajan in data:
26
+ # category = BhajanCategory.objects.filter(link=bhajan['CatId']).first()
27
+ # Bhajan.objects.create(
28
+ # title=bhajan['title'],
29
+ # title_guj=bhajan['title_guj'],
30
+ # category=category,
31
+ # lyrics=bhajan['lyrics'],
32
+ # isEng = bhajan['isEng'],
33
+ # isHnd = bhajan['isHnd'],
34
+ # isGer = bhajan['isGer'],
35
+ # isAudio = bhajan['isAudio'],
36
+ # audio_url=bhajan['audio_url'] if bhajan['isAudio'] else ""
37
+ # )
38
+ # print(bhajan['title'])
39
+ return HttpResponse("Data Entry Page")
40
+
41
+ def bhajanCategoryList(request):
42
+ categories = BhajanCategory.objects.all()
43
+ bhajans = Bhajan.objects.all()
44
+ bhajanArr = []
45
+ for bhajan in bhajans:
46
+ bhajanArr.append({
47
+ "id": bhajan.bhajanId,
48
+ "title": bhajan.title,
49
+ "title_guj": bhajan.title_guj,
50
+ "category": bhajan.category.name,
51
+ "lyrics": bhajan.lyrics,
52
+ "audio_url": bhajan.audio_url,
53
+ "isEng": bhajan.isEng,
54
+ "isHnd": bhajan.isHnd,
55
+ "isGer": bhajan.isGer,
56
+ "isAudio": bhajan.isAudio
57
+ })
58
+ categoryArr = []
59
+ for category in categories:
60
+ categoryArr.append({
61
+ "name": category.name,
62
+ "link": category.link
63
+ })
64
+ lyricsBase = "https://huggingface.co/spaces/thejagstudio/MusicStore/raw/main/HTML Files/"
65
+ audioBase = "https://huggingface.co/spaces/thejagstudio/MusicStore/resolve/main/Bhajan Audio/"
66
+ return JsonResponse({"categories": categoryArr, "bhajans": bhajanArr, "lyricsBase": lyricsBase, "audioBase": audioBase})
67
+
68
+ def bhajanDetail(request,id):
69
+ bhajan = Bhajan.objects.get(bhajanId=id)
70
+ if bhajan is None:
71
+ return JsonResponse({"error": "Bhajan not found"})
72
+ else:
73
+ return JsonResponse({
74
+ "id": bhajan.bhajanId,
75
+ "title": bhajan.title,
76
+ "title_guj": bhajan.title_guj,
77
+ "category": bhajan.category.name,
78
+ "lyrics": bhajan.lyrics,
79
+ "audio_url": bhajan.audio_url,
80
+ "isEng": bhajan.isEng,
81
+ "isHnd": bhajan.isHnd,
82
+ "isGer": bhajan.isGer,
83
+ "isAudio": bhajan.isAudio,
84
+ "lyricsBase": "https://huggingface.co/spaces/thejagstudio/MusicStore/raw/main/HTML Files/",
85
+ "audioBase": "https://huggingface.co/spaces/thejagstudio/MusicStore/resolve/main/Bhajan Audio/"
86
+ })
87
+ return HttpResponse("Bhajan Detail Page")
88
+
89
+ def eventList(request):
90
+ events = Event.objects.all()
91
+ eventArr = []
92
+ for event in events:
93
+ # convert date to Sept 26,2024 | 8:30 - 9:30
94
+ dateFormatted = event.date.strftime("%b %d, %Y") + " | " + event.date.strftime("%I:%M %p") + " - " + event.time.strftime("%I:%M %p")
95
+ eventArr.append({
96
+ "title":event.title,
97
+ "description":event.description,
98
+ "date": dateFormatted,
99
+ "day":int(event.date.strftime("%d")),
100
+ "month":int(event.date.strftime("%m")),
101
+ "year":int(event.date.strftime("%Y")),
102
+ "created_by":event.created_by.__str__(),
103
+ "region":event.region.name,
104
+ "is_approved":event.is_approved,
105
+ "color":event.color
106
+ })
107
+ return JsonResponse({"events": eventArr})
108
+
109
+ @login_required
110
+ def dashboard(request):
111
+ user = request.user
112
+ context = {
113
+ 'user': user,
114
+ }
115
+ if user.user_type == 'superadmin':
116
+ context['users'] = Bhagat.objects.all()
117
+ context['events'] = Event.objects.all()
118
+ elif user.user_type == 'regionadmin':
119
+ context['monitors'] = Bhagat.objects.filter(user_type='monitor', region=user.region)
120
+ context['users'] = Bhagat.objects.filter(user_type='user', region=user.region)
121
+ context['events'] = Event.objects.filter(region=user.region)
122
+ elif user.user_type == 'monitor':
123
+ context['users'] = Bhagat.objects.filter(assigned_to=user)
124
+ context['events'] = Event.objects.filter(region=user.region)
125
+ else: # regular user
126
+ context['events'] = Event.objects.filter(region=user.region, is_approved=True)
127
+
128
+ return render(request, 'dashboard.html', context)
129
+
130
+
131
+ @user_passes_test(is_superadmin)
132
+ def manage_users(request):
133
+ if request.method == 'POST':
134
+ # Handle user creation/modification
135
+ pass
136
+ users = Bhagat.objects.all()
137
+ return render(request, 'manage_users.html', {'users': users})
138
+
139
+
140
+ @user_passes_test(is_regionadmin)
141
+ def create_event(request):
142
+ if request.method == 'POST':
143
+ # Handle event creation
144
+ pass
145
+ return render(request, 'create_event.html')
146
+
147
+
148
+ @user_passes_test(is_superadmin)
149
+ def approve_event(request, event_id):
150
+ event = get_object_or_404(Event, id=event_id)
151
+ event.is_approved = True
152
+ event.save()
153
+ return redirect('event_list')
154
+
155
+
156
+ @login_required
157
+ @require_POST
158
+ def update_attendance(request, event_id):
159
+ event = get_object_or_404(Event, id=event_id)
160
+ status = request.POST.get('status')
161
+ attendance, created = Attendance.objects.update_or_create(
162
+ user=request.user,
163
+ event=event,
164
+ defaults={'status': status}
165
+ )
166
+ return JsonResponse({'status': 'success'})
167
+
168
+
169
+ @login_required
170
+ def send_message(request):
171
+ if request.method == 'POST':
172
+ recipient_id = request.POST.get('recipient')
173
+ content = request.POST.get('content')
174
+ recipient = get_object_or_404(Bhagat, id=recipient_id)
175
+ Message.objects.create(sender=request.user, recipient=recipient, content=content)
176
+ return redirect('messages')
177
+
178
+
179
+ @user_passes_test(is_superadmin)
180
+ def send_notification(request):
181
+ if request.method == 'POST':
182
+ content = request.POST.get('content')
183
+ recipient_type = request.POST.get('recipient_type')
184
+ if recipient_type == 'all':
185
+ recipients = Bhagat.objects.all()
186
+ elif recipient_type == 'monitors':
187
+ recipients = Bhagat.objects.filter(user_type='monitor')
188
+ elif recipient_type == 'regionadmins':
189
+ recipients = Bhagat.objects.filter(user_type='regionadmin')
190
+
191
+ notification = Notification.objects.create(sender=request.user, content=content, notification_type='custom')
192
+ notification.recipients.set(recipients)
193
+
194
+ return redirect('notifications')
195
+
196
+
197
+ def birthday_notifications():
198
+ today = timezone.now().date()
199
+ birthday_users = Bhagat.objects.filter(birthday__month=today.month, birthday__day=today.day)
200
+ for user in birthday_users:
201
+ notification = Notification.objects.create(
202
+ sender=Bhagat.objects.get(user_type='superadmin'),
203
+ content=f"Happy Birthday to {user.get_full_name()}!",
204
+ notification_type='birthday'
205
+ )
206
+ notification.recipients.set(Bhagat.objects.all())
db.sqlite3 ADDED
Binary file (336 kB). View file
 
extra/bhajanData.json ADDED
The diff for this file is too large to render. See raw diff
 
extra/bhajanEntry.txt ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ with open("./api/bhajanData.json", "r",encoding="utf-8") as f:
2
+ data = json.load(f)["Prasang"]
3
+ for bhajan in data:
4
+ category = BhajanCategory.objects.filter(link=bhajan['CatId']).first()
5
+ Bhajan.objects.create(
6
+ title=bhajan['title'],
7
+ title_guj=bhajan['title_guj'],
8
+ category=category,
9
+ lyrics=bhajan['lyrics'],
10
+ isEng = bhajan['isEng'],
11
+ isHnd = bhajan['isHnd'],
12
+ isGer = bhajan['isGer'],
13
+ isAudio = bhajan['isAudio'],
14
+ audio_url=bhajan['audio_url'] if bhajan['isAudio'] else ""
15
+ )
16
+ print(bhajan['title'])
hsapssconnect/__init__.py ADDED
File without changes
hsapssconnect/__pycache__/__init__.cpython-311.pyc ADDED
Binary file (174 Bytes). View file
 
hsapssconnect/__pycache__/__init__.cpython-39.pyc ADDED
Binary file (156 Bytes). View file
 
hsapssconnect/__pycache__/settings.cpython-311.pyc ADDED
Binary file (2.62 kB). View file
 
hsapssconnect/__pycache__/settings.cpython-39.pyc ADDED
Binary file (2.5 kB). View file
 
hsapssconnect/__pycache__/urls.cpython-39.pyc ADDED
Binary file (367 Bytes). View file
 
hsapssconnect/__pycache__/wsgi.cpython-39.pyc ADDED
Binary file (571 Bytes). View file
 
hsapssconnect/asgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ ASGI config for hsapssconnect project.
3
+
4
+ It exposes the ASGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/howto/deployment/asgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.asgi import get_asgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hsapssconnect.settings")
15
+
16
+ application = get_asgi_application()
hsapssconnect/settings.py ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Django settings for hsapssconnect project.
3
+
4
+ Generated by 'django-admin startproject' using Django 5.0.6.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/topics/settings/
8
+
9
+ For the full list of settings and their values, see
10
+ https://docs.djangoproject.com/en/5.0/ref/settings/
11
+ """
12
+
13
+ from pathlib import Path
14
+
15
+ # Build paths inside the project like this: BASE_DIR / 'subdir'.
16
+ BASE_DIR = Path(__file__).resolve().parent.parent
17
+
18
+
19
+ # Quick-start development settings - unsuitable for production
20
+ # See https://docs.djangoproject.com/en/5.0/howto/deployment/checklist/
21
+
22
+ # SECURITY WARNING: keep the secret key used in production secret!
23
+ SECRET_KEY = "django-insecure-lde0hgz*y9#h@sbz_u6&=&=i9cef23em^sax91iqb_)1#2s*qd"
24
+
25
+ # SECURITY WARNING: don't run with debug turned on in production!
26
+ DEBUG = True
27
+
28
+ ALLOWED_HOSTS = ["*", "127.0.0.1", "localhost"]
29
+ CORS_ORIGIN_ALLOW_ALL = True
30
+ CORS_ALLOW_CREDENTIALS = False
31
+
32
+ # SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
33
+ # SECURE_SSL_REDIRECT = True
34
+ # SESSION_COOKIE_SECURE = True
35
+ # CSRF_COOKIE_SECURE = True
36
+
37
+
38
+ # Application definition
39
+
40
+ INSTALLED_APPS = [
41
+ "django.contrib.admin",
42
+ "django.contrib.auth",
43
+ "django.contrib.contenttypes",
44
+ "django.contrib.sessions",
45
+ "django.contrib.messages",
46
+ "django.contrib.staticfiles",
47
+ "api",
48
+ "corsheaders",
49
+ "import_export",
50
+ ]
51
+
52
+ MIDDLEWARE = [
53
+ "django.middleware.security.SecurityMiddleware",
54
+ "django.contrib.sessions.middleware.SessionMiddleware",
55
+ 'corsheaders.middleware.CorsMiddleware',
56
+ "django.middleware.common.CommonMiddleware",
57
+ "django.middleware.csrf.CsrfViewMiddleware",
58
+ "django.contrib.auth.middleware.AuthenticationMiddleware",
59
+ "django.contrib.messages.middleware.MessageMiddleware",
60
+ "django.middleware.clickjacking.XFrameOptionsMiddleware",
61
+ ]
62
+
63
+ ROOT_URLCONF = "hsapssconnect.urls"
64
+
65
+ TEMPLATES = [
66
+ {
67
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
68
+ "DIRS": [],
69
+ "APP_DIRS": True,
70
+ "OPTIONS": {
71
+ "context_processors": [
72
+ "django.template.context_processors.debug",
73
+ "django.template.context_processors.request",
74
+ "django.contrib.auth.context_processors.auth",
75
+ "django.contrib.messages.context_processors.messages",
76
+ ],
77
+ },
78
+ },
79
+ ]
80
+
81
+ WSGI_APPLICATION = "hsapssconnect.wsgi.application"
82
+
83
+
84
+ # Database
85
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#databases
86
+
87
+ DATABASES = {
88
+ "default": {
89
+ "ENGINE": "django.db.backends.sqlite3",
90
+ "NAME": BASE_DIR / "db.sqlite3",
91
+ }
92
+ }
93
+
94
+
95
+ # Password validation
96
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators
97
+
98
+ AUTH_PASSWORD_VALIDATORS = [
99
+ {
100
+ "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
101
+ },
102
+ {
103
+ "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
104
+ },
105
+ {
106
+ "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
107
+ },
108
+ {
109
+ "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
110
+ },
111
+ ]
112
+
113
+
114
+ # Internationalization
115
+ # https://docs.djangoproject.com/en/5.0/topics/i18n/
116
+
117
+ LANGUAGE_CODE = "en-us"
118
+
119
+ TIME_ZONE = "UTC"
120
+
121
+ USE_I18N = True
122
+
123
+ USE_TZ = True
124
+
125
+
126
+ # Static files (CSS, JavaScript, Images)
127
+ # https://docs.djangoproject.com/en/5.0/howto/static-files/
128
+
129
+ STATIC_URL = "static/"
130
+
131
+ # Default primary key field type
132
+ # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
133
+
134
+ DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
135
+ AUTH_USER_MODEL = 'api.Bhagat'
hsapssconnect/urls.py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ from django.contrib import admin
2
+ from django.urls import path
3
+ from django.urls.conf import include
4
+
5
+ urlpatterns = [
6
+ path("admin/", admin.site.urls),
7
+ path("api/", include("api.urls")),
8
+ ]
hsapssconnect/wsgi.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ WSGI config for hsapssconnect project.
3
+
4
+ It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+ For more information on this file, see
7
+ https://docs.djangoproject.com/en/5.0/howto/deployment/wsgi/
8
+ """
9
+
10
+ import os
11
+
12
+ from django.core.wsgi import get_wsgi_application
13
+
14
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hsapssconnect.settings")
15
+
16
+ application = get_wsgi_application()
manage.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """Django's command-line utility for administrative tasks."""
3
+ import os
4
+ import sys
5
+
6
+
7
+ def main():
8
+ """Run administrative tasks."""
9
+ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hsapssconnect.settings")
10
+ try:
11
+ from django.core.management import execute_from_command_line
12
+ except ImportError as exc:
13
+ raise ImportError(
14
+ "Couldn't import Django. Are you sure it's installed and "
15
+ "available on your PYTHONPATH environment variable? Did you "
16
+ "forget to activate a virtual environment?"
17
+ ) from exc
18
+ execute_from_command_line(sys.argv)
19
+
20
+
21
+ if __name__ == "__main__":
22
+ main()