Spaces:
Running
Running
thejagstudio
commited on
Commit
•
4618a46
1
Parent(s):
aff4b27
Upload 54 files
Browse files- api/__pycache__/admin.cpython-39.pyc +0 -0
- api/__pycache__/models.cpython-39.pyc +0 -0
- api/__pycache__/urls.cpython-39.pyc +0 -0
- api/__pycache__/views.cpython-39.pyc +0 -0
- api/admin.py +8 -3
- api/migrations/0011_delete_message.py +15 -0
- api/migrations/0012_notification_title.py +17 -0
- api/migrations/__pycache__/0011_delete_message.cpython-39.pyc +0 -0
- api/migrations/__pycache__/0012_notification_title.cpython-39.pyc +0 -0
- api/models.py +3 -10
- api/urls.py +2 -6
- api/views.py +15 -69
- db.sqlite3 +0 -0
- hsapssconnect/__pycache__/settings.cpython-39.pyc +0 -0
- hsapssconnect/settings.py +1 -1
api/__pycache__/admin.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/admin.cpython-39.pyc and b/api/__pycache__/admin.cpython-39.pyc differ
|
|
api/__pycache__/models.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/models.cpython-39.pyc and b/api/__pycache__/models.cpython-39.pyc differ
|
|
api/__pycache__/urls.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/urls.cpython-39.pyc and b/api/__pycache__/urls.cpython-39.pyc differ
|
|
api/__pycache__/views.cpython-39.pyc
CHANGED
Binary files a/api/__pycache__/views.cpython-39.pyc and b/api/__pycache__/views.cpython-39.pyc differ
|
|
api/admin.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
from django.contrib import admin
|
2 |
-
from .models import Bhagat, Event, Attendance,
|
3 |
from import_export.admin import ImportExportModelAdmin
|
4 |
|
5 |
# Register your models here.
|
@@ -17,7 +17,7 @@ class BhajanCategoryAdmin(ImportExportModelAdmin):
|
|
17 |
|
18 |
class BhajanAdmin(ImportExportModelAdmin):
|
19 |
list_display = ('title', 'title_guj', 'category', 'lyricsBtn')
|
20 |
-
search_fields = ('title', 'title_guj', '
|
21 |
list_filter = ('category',)
|
22 |
# 'musicPreivew',
|
23 |
|
@@ -27,9 +27,14 @@ class EventAdmin(ImportExportModelAdmin):
|
|
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 |
-
|
|
|
1 |
from django.contrib import admin
|
2 |
+
from .models import Bhagat, Event, Attendance, Notification, Region, BhajanCategory, Bhajan
|
3 |
from import_export.admin import ImportExportModelAdmin
|
4 |
|
5 |
# Register your models here.
|
|
|
17 |
|
18 |
class BhajanAdmin(ImportExportModelAdmin):
|
19 |
list_display = ('title', 'title_guj', 'category', 'lyricsBtn')
|
20 |
+
search_fields = ('title', 'title_guj', 'category__name')
|
21 |
list_filter = ('category',)
|
22 |
# 'musicPreivew',
|
23 |
|
|
|
27 |
search_fields = ('title', 'date', 'region', 'is_approved', 'color')
|
28 |
list_editable = ('is_approved', 'color')
|
29 |
|
30 |
+
class NotificationAdmin(ImportExportModelAdmin):
|
31 |
+
list_display = ('sender', 'title','timestamp', 'notification_type')
|
32 |
+
list_filter = ('notification_type',)
|
33 |
+
search_fields = ('sender__first_name', 'title', 'notification_type')
|
34 |
+
|
35 |
admin.site.register(Bhagat, BhagatAdmin)
|
36 |
admin.site.register(Region, RegionAdmin)
|
37 |
admin.site.register(BhajanCategory, BhajanCategoryAdmin)
|
38 |
admin.site.register(Bhajan, BhajanAdmin)
|
39 |
admin.site.register(Event, EventAdmin)
|
40 |
+
admin.site.register(Notification, NotificationAdmin)
|
api/migrations/0011_delete_message.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-09-24 13:55
|
2 |
+
|
3 |
+
from django.db import migrations
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("api", "0010_event_time"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.DeleteModel(
|
13 |
+
name="Message",
|
14 |
+
),
|
15 |
+
]
|
api/migrations/0012_notification_title.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Generated by Django 4.2.16 on 2024-09-24 14:21
|
2 |
+
|
3 |
+
from django.db import migrations, models
|
4 |
+
|
5 |
+
|
6 |
+
class Migration(migrations.Migration):
|
7 |
+
dependencies = [
|
8 |
+
("api", "0011_delete_message"),
|
9 |
+
]
|
10 |
+
|
11 |
+
operations = [
|
12 |
+
migrations.AddField(
|
13 |
+
model_name="notification",
|
14 |
+
name="title",
|
15 |
+
field=models.CharField(blank=True, max_length=200, null=True),
|
16 |
+
),
|
17 |
+
]
|
api/migrations/__pycache__/0011_delete_message.cpython-39.pyc
ADDED
Binary file (487 Bytes). View file
|
|
api/migrations/__pycache__/0012_notification_title.cpython-39.pyc
ADDED
Binary file (609 Bytes). View file
|
|
api/models.py
CHANGED
@@ -7,7 +7,7 @@ class Bhagat(AbstractUser):
|
|
7 |
USER_TYPES = (
|
8 |
('superadmin', 'Super Admin'),
|
9 |
('regionadmin', 'Region Admin'),
|
10 |
-
('
|
11 |
('user', 'User'),
|
12 |
)
|
13 |
MEMBER_TYPES = (
|
@@ -55,20 +55,13 @@ class Attendance(models.Model):
|
|
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=((
|
72 |
|
73 |
class BhajanCategory(models.Model):
|
74 |
name = models.CharField(max_length=100)
|
|
|
7 |
USER_TYPES = (
|
8 |
('superadmin', 'Super Admin'),
|
9 |
('regionadmin', 'Region Admin'),
|
10 |
+
('karyakarta', 'Karyakarta'),
|
11 |
('user', 'User'),
|
12 |
)
|
13 |
MEMBER_TYPES = (
|
|
|
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 |
class Notification(models.Model):
|
59 |
sender = models.ForeignKey(Bhagat, on_delete=models.CASCADE, related_name='sent_notifications')
|
60 |
recipients = models.ManyToManyField(Bhagat, related_name='received_notifications')
|
61 |
+
title = models.CharField(max_length=200, blank=True, null=True)
|
62 |
content = models.TextField()
|
63 |
timestamp = models.DateTimeField(auto_now_add=True)
|
64 |
+
notification_type = models.CharField(max_length=20, choices=(("orange", "Shabha"), ("green", "Activity"), ("blue", "Birthday"), ("red", "Important"), ("purple", "Gathering"), ("yellow", "Festival"), ("pink", "Custom")))
|
65 |
|
66 |
class BhajanCategory(models.Model):
|
67 |
name = models.CharField(max_length=100)
|
api/urls.py
CHANGED
@@ -2,16 +2,12 @@ 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 |
]
|
|
|
2 |
from . import views
|
3 |
|
4 |
urlpatterns = [
|
|
|
5 |
path('dataEntry/', views.dataEntry, name='dataEntry'),
|
|
|
|
|
|
|
|
|
|
|
6 |
path('send-notification/', views.send_notification, name='send_notification'),
|
7 |
|
8 |
path('bhajan-category-list/', views.bhajanCategoryList, name='bhajanCategoryList'),
|
9 |
path('bhajan-detail/<int:id>', views.bhajanDetail, name='bhajanDetail'),
|
10 |
path('event-list/', views.eventList, name='eventList'),
|
11 |
+
path('notification-list/', views.notificationList, name='notificationList'),
|
12 |
+
|
13 |
]
|
api/views.py
CHANGED
@@ -1,11 +1,10 @@
|
|
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,
|
9 |
|
10 |
|
11 |
def is_superadmin(user):
|
@@ -86,6 +85,7 @@ def bhajanDetail(request,id):
|
|
86 |
})
|
87 |
return HttpResponse("Bhajan Detail Page")
|
88 |
|
|
|
89 |
def eventList(request):
|
90 |
events = Event.objects.all()
|
91 |
eventArr = []
|
@@ -106,74 +106,20 @@ def eventList(request):
|
|
106 |
})
|
107 |
return JsonResponse({"events": eventArr})
|
108 |
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
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)
|
|
|
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 django.views.decorators.http import require_POST
|
5 |
from django.utils import timezone
|
6 |
import json
|
7 |
+
from .models import Bhagat, Event, Attendance, Notification, Region, BhajanCategory, Bhajan
|
8 |
|
9 |
|
10 |
def is_superadmin(user):
|
|
|
85 |
})
|
86 |
return HttpResponse("Bhajan Detail Page")
|
87 |
|
88 |
+
|
89 |
def eventList(request):
|
90 |
events = Event.objects.all()
|
91 |
eventArr = []
|
|
|
106 |
})
|
107 |
return JsonResponse({"events": eventArr})
|
108 |
|
109 |
+
def notificationList(request):
|
110 |
+
notifications = Notification.objects.all()
|
111 |
+
notificationArr = []
|
112 |
+
for notification in notifications:
|
113 |
+
notificationArr.append({
|
114 |
+
"sender":notification.sender.__str__(),
|
115 |
+
"category": notification.sender.user_type,
|
116 |
+
"title":notification.title,
|
117 |
+
"content":notification.content,
|
118 |
+
"timestamp":notification.timestamp.strftime("%b %d, %Y | %I:%M %p"),
|
119 |
+
"notification_type":notification.notification_type
|
120 |
+
})
|
121 |
+
return JsonResponse({"notifications": notificationArr})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
|
124 |
|
125 |
@user_passes_test(is_superadmin)
|
db.sqlite3
CHANGED
Binary files a/db.sqlite3 and b/db.sqlite3 differ
|
|
hsapssconnect/__pycache__/settings.cpython-39.pyc
CHANGED
Binary files a/hsapssconnect/__pycache__/settings.cpython-39.pyc and b/hsapssconnect/__pycache__/settings.cpython-39.pyc differ
|
|
hsapssconnect/settings.py
CHANGED
@@ -116,7 +116,7 @@ AUTH_PASSWORD_VALIDATORS = [
|
|
116 |
|
117 |
LANGUAGE_CODE = "en-us"
|
118 |
|
119 |
-
TIME_ZONE = "
|
120 |
|
121 |
USE_I18N = True
|
122 |
|
|
|
116 |
|
117 |
LANGUAGE_CODE = "en-us"
|
118 |
|
119 |
+
TIME_ZONE = "EST"
|
120 |
|
121 |
USE_I18N = True
|
122 |
|