diff --git a/.DS_Store b/.DS_Store index 53cac9de..8c5e2f68 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/osinaweb/.DS_Store b/osinaweb/.DS_Store index bfc92706..98fc8248 100644 Binary files a/osinaweb/.DS_Store and b/osinaweb/.DS_Store differ diff --git a/osinaweb/db.sqlite3 b/osinaweb/db.sqlite3 index e34fc978..23cc8f0d 100644 Binary files a/osinaweb/db.sqlite3 and b/osinaweb/db.sqlite3 differ diff --git a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc index eecff37a..e86a4fd3 100644 Binary files a/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc and b/osinaweb/osichat/__pycache__/consumers.cpython-310.pyc differ diff --git a/osinaweb/osichat/consumers.py b/osinaweb/osichat/consumers.py index d68a3f54..fcf25ec6 100644 --- a/osinaweb/osichat/consumers.py +++ b/osinaweb/osichat/consumers.py @@ -124,6 +124,7 @@ class Osichat(WebsocketConsumer): if hasattr(chat_room, 'chatroomguest') and chat_room.chatroomguest.visitor: visitor = chat_room.chatroomguest.visitor room_data['visitor'] = { + 'id': visitor.id, 'session_id': visitor.session_id, 'ip': visitor.ip_address, 'country': visitor.country, diff --git a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc index 728a872c..716b6eef 100644 Binary files a/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/admin.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc index e3b28deb..54ca5036 100644 Binary files a/osinaweb/osinacore/__pycache__/models.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/models.cpython-310.pyc differ diff --git a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc index 1a3fc79d..b2b73f94 100644 Binary files a/osinaweb/osinacore/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc index 93a95740..a2f2aa82 100644 Binary files a/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc index cd0823a7..d651c171 100644 Binary files a/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/add/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/add/urls.py b/osinaweb/osinacore/add/urls.py index cc4a74e7..2016ab14 100644 --- a/osinaweb/osinacore/add/urls.py +++ b/osinaweb/osinacore/add/urls.py @@ -13,8 +13,8 @@ urlpatterns = [ path('project/', views.add_project, name='addproject'), path('project-member//', views.add_project_member_modal, name='addprojectmembermodal'), path('project-story//', views.add_user_story_modal, name='adduserstorymodal'), - path('project-file/', views.add_file_modal, name='addfilemodal'), - path('project-credential/', views.add_credential_modal, name='addcredentialmodal'), + path('project-file//', views.add_file_modal, name='addfilemodal'), + path('project-credential//', views.add_credential_modal, name='addcredentialmodal'), path('project-note//', views.add_note_modal, name='addprojectnotemodal'), diff --git a/osinaweb/osinacore/add/views.py b/osinaweb/osinacore/add/views.py index 4d6eed31..7ec10f20 100644 --- a/osinaweb/osinacore/add/views.py +++ b/osinaweb/osinacore/add/views.py @@ -296,19 +296,43 @@ def add_user_story_modal(request, project_id): @staff_login_required -def add_file_modal(request, *args, **kwargs): +def add_file_modal(request, project_id): + project = get_object_or_404(Project, project_id=project_id) + if request.method == 'POST': + project_file_album = ProjectFileAlbum.objects.create( + project = project, + name = request.POST.get('name'), + ) + for file in request.FILES.getlist('files'): + ProjectFile.objects.create( + album=project_file_album, + file = file, + date_added= datetime.now() + ) + return HttpResponse('') context = { + 'project': project } return render(request, 'add_templates/add-file-modal.html', context) -def add_credential_modal(request, *args, **kwargs): +def add_credential_modal(request, project_id): + project = get_object_or_404(Project, project_id=project_id) + if request.method == 'POST': + ProjectCredential.objects.create( + identifier = request.POST.get('identifier'), + password = request.POST.get('password'), + description = request.POST.get('description'), + date_added = datetime.now(), + project = project + ) + return HttpResponse('') context = { - + 'project': project, } - return render(request, 'add_templates/add-credentials-modal.html', context) + return render(request, 'add_templates/add-credential-modal.html', context) diff --git a/osinaweb/osinacore/admin.py b/osinaweb/osinacore/admin.py index 4fea3d9f..ffcbd2ab 100644 --- a/osinaweb/osinacore/admin.py +++ b/osinaweb/osinacore/admin.py @@ -9,16 +9,14 @@ class RequirementInline(admin.TabularInline): extra = 1 -class FileInline(admin.TabularInline): - model = ProjectFile - extra = 1 + class CredentialInline(admin.TabularInline): model = ProjectCredential extra = 1 class ProjectAdmin(admin.ModelAdmin): - inlines=[RequirementInline, FileInline, CredentialInline] + inlines=[RequirementInline, CredentialInline] diff --git a/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc b/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc index 03448eec..0a75fbf9 100644 Binary files a/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc and b/osinaweb/osinacore/api/__pycache__/urls.cpython-310.pyc differ diff --git a/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc b/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc index 1e267ae0..a040a887 100644 Binary files a/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc and b/osinaweb/osinacore/api/__pycache__/views.cpython-310.pyc differ diff --git a/osinaweb/osinacore/api/urls.py b/osinaweb/osinacore/api/urls.py index abc39652..ad939256 100644 --- a/osinaweb/osinacore/api/urls.py +++ b/osinaweb/osinacore/api/urls.py @@ -3,6 +3,6 @@ from . import views urlpatterns = [ - path('login/', views.login_user) - + path('login/', views.login_user), + path('register-device/', views.register_device) ] \ No newline at end of file diff --git a/osinaweb/osinacore/api/views.py b/osinaweb/osinacore/api/views.py index cdc175f5..7d63ec93 100644 --- a/osinaweb/osinacore/api/views.py +++ b/osinaweb/osinacore/api/views.py @@ -6,7 +6,7 @@ import calendar from django.contrib.auth.hashers import check_password from datetime import datetime import datetime as datetime2 - +from fcm_django.models import FCMDevice @api_view(['POST']) def login_user(request): @@ -32,4 +32,21 @@ def login_user(request): return errorRes(msg=str(err)) except Exception as e: print(e) - return errorRes(msg=str(e)) \ No newline at end of file + return errorRes(msg=str(e)) + + +@api_view(['POST']) +def register_device(request): + try: + registration_token = request.data.get('registration_token') + device_type = request.data.get('device_type') + # Check if the device already exists + existing_device = FCMDevice.objects.get(registration_id=registration_token) + return errorRes(msg='Device already registered') + except FCMDevice.DoesNotExist: + # Create a new device + device = FCMDevice(registration_id=registration_token, type=device_type) + device.save() + return successRes(msg="Device registered successfully.") + except Exception as e: + return errorRes(str(e)) \ No newline at end of file diff --git a/osinaweb/osinacore/migrations/0098_rename_emailorusername_projectcredential_identifier.py b/osinaweb/osinacore/migrations/0098_rename_emailorusername_projectcredential_identifier.py new file mode 100644 index 00000000..2e8b8033 --- /dev/null +++ b/osinaweb/osinacore/migrations/0098_rename_emailorusername_projectcredential_identifier.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-08-14 06:26 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0097_remove_status_date_remove_status_time'), + ] + + operations = [ + migrations.RenameField( + model_name='projectcredential', + old_name='emailorusername', + new_name='identifier', + ), + ] diff --git a/osinaweb/osinacore/migrations/0099_remove_projectcredential_usedfor_and_more.py b/osinaweb/osinacore/migrations/0099_remove_projectcredential_usedfor_and_more.py new file mode 100644 index 00000000..3bd397c9 --- /dev/null +++ b/osinaweb/osinacore/migrations/0099_remove_projectcredential_usedfor_and_more.py @@ -0,0 +1,22 @@ +# Generated by Django 4.2.5 on 2024-08-14 06:31 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0098_rename_emailorusername_projectcredential_identifier'), + ] + + operations = [ + migrations.RemoveField( + model_name='projectcredential', + name='usedfor', + ), + migrations.AddField( + model_name='projectcredential', + name='description', + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/osinaweb/osinacore/migrations/0100_projectcredential_date_added.py b/osinaweb/osinacore/migrations/0100_projectcredential_date_added.py new file mode 100644 index 00000000..ac9d2a59 --- /dev/null +++ b/osinaweb/osinacore/migrations/0100_projectcredential_date_added.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-08-14 06:33 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0099_remove_projectcredential_usedfor_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='projectcredential', + name='date_added', + field=models.DateTimeField(null=True), + ), + ] diff --git a/osinaweb/osinacore/migrations/0101_rename_date_projectfile_date_added.py b/osinaweb/osinacore/migrations/0101_rename_date_projectfile_date_added.py new file mode 100644 index 00000000..0498c08b --- /dev/null +++ b/osinaweb/osinacore/migrations/0101_rename_date_projectfile_date_added.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-08-14 07:02 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0100_projectcredential_date_added'), + ] + + operations = [ + migrations.RenameField( + model_name='projectfile', + old_name='date', + new_name='date_added', + ), + ] diff --git a/osinaweb/osinacore/migrations/0102_remove_projectfile_date_added_and_more.py b/osinaweb/osinacore/migrations/0102_remove_projectfile_date_added_and_more.py new file mode 100644 index 00000000..81ed7395 --- /dev/null +++ b/osinaweb/osinacore/migrations/0102_remove_projectfile_date_added_and_more.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.5 on 2024-08-14 07:06 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0101_rename_date_projectfile_date_added'), + ] + + operations = [ + migrations.RemoveField( + model_name='projectfile', + name='date_added', + ), + migrations.RemoveField( + model_name='projectfile', + name='file', + ), + migrations.CreateModel( + name='ProjectFileAlbum', + fields=[ + ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('date_added', models.DateField()), + ('projectfile', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='osinacore.projectfile')), + ], + ), + ] diff --git a/osinaweb/osinacore/migrations/0103_alter_projectfilealbum_date_added.py b/osinaweb/osinacore/migrations/0103_alter_projectfilealbum_date_added.py new file mode 100644 index 00000000..6e7254f9 --- /dev/null +++ b/osinaweb/osinacore/migrations/0103_alter_projectfilealbum_date_added.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-08-14 07:08 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0102_remove_projectfile_date_added_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='projectfilealbum', + name='date_added', + field=models.DateTimeField(), + ), + ] diff --git a/osinaweb/osinacore/migrations/0104_projectfilealbum_file.py b/osinaweb/osinacore/migrations/0104_projectfilealbum_file.py new file mode 100644 index 00000000..18c36d16 --- /dev/null +++ b/osinaweb/osinacore/migrations/0104_projectfilealbum_file.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.5 on 2024-08-14 07:13 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0103_alter_projectfilealbum_date_added'), + ] + + operations = [ + migrations.AddField( + model_name='projectfilealbum', + name='file', + field=models.FileField(null=True, upload_to=''), + ), + ] diff --git a/osinaweb/osinacore/migrations/0105_remove_projectfile_name_remove_projectfile_project_and_more.py b/osinaweb/osinacore/migrations/0105_remove_projectfile_name_remove_projectfile_project_and_more.py new file mode 100644 index 00000000..8f731cb6 --- /dev/null +++ b/osinaweb/osinacore/migrations/0105_remove_projectfile_name_remove_projectfile_project_and_more.py @@ -0,0 +1,59 @@ +# Generated by Django 4.2.5 on 2024-08-14 07:17 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('osinacore', '0104_projectfilealbum_file'), + ] + + operations = [ + migrations.RemoveField( + model_name='projectfile', + name='name', + ), + migrations.RemoveField( + model_name='projectfile', + name='project', + ), + migrations.RemoveField( + model_name='projectfilealbum', + name='date_added', + ), + migrations.RemoveField( + model_name='projectfilealbum', + name='file', + ), + migrations.RemoveField( + model_name='projectfilealbum', + name='projectfile', + ), + migrations.AddField( + model_name='projectfile', + name='album', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='osinacore.projectfilealbum'), + ), + migrations.AddField( + model_name='projectfile', + name='date_added', + field=models.DateTimeField(null=True), + ), + migrations.AddField( + model_name='projectfile', + name='file', + field=models.FileField(null=True, upload_to=''), + ), + migrations.AddField( + model_name='projectfilealbum', + name='name', + field=models.CharField(max_length=350, null=True), + ), + migrations.AddField( + model_name='projectfilealbum', + name='project', + field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='osinacore.project'), + ), + ] diff --git a/osinaweb/osinacore/migrations/__pycache__/0098_rename_emailorusername_projectcredential_identifier.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0098_rename_emailorusername_projectcredential_identifier.cpython-310.pyc new file mode 100644 index 00000000..bd048988 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0098_rename_emailorusername_projectcredential_identifier.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0099_remove_projectcredential_usedfor_and_more.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0099_remove_projectcredential_usedfor_and_more.cpython-310.pyc new file mode 100644 index 00000000..64685990 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0099_remove_projectcredential_usedfor_and_more.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0100_projectcredential_date_added.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0100_projectcredential_date_added.cpython-310.pyc new file mode 100644 index 00000000..a1db426d Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0100_projectcredential_date_added.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0101_rename_date_projectfile_date_added.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0101_rename_date_projectfile_date_added.cpython-310.pyc new file mode 100644 index 00000000..fa3bf8ea Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0101_rename_date_projectfile_date_added.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0102_remove_projectfile_date_added_and_more.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0102_remove_projectfile_date_added_and_more.cpython-310.pyc new file mode 100644 index 00000000..e108ca76 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0102_remove_projectfile_date_added_and_more.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0103_alter_projectfilealbum_date_added.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0103_alter_projectfilealbum_date_added.cpython-310.pyc new file mode 100644 index 00000000..940df0e9 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0103_alter_projectfilealbum_date_added.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0104_projectfilealbum_file.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0104_projectfilealbum_file.cpython-310.pyc new file mode 100644 index 00000000..e74408d2 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0104_projectfilealbum_file.cpython-310.pyc differ diff --git a/osinaweb/osinacore/migrations/__pycache__/0105_remove_projectfile_name_remove_projectfile_project_and_more.cpython-310.pyc b/osinaweb/osinacore/migrations/__pycache__/0105_remove_projectfile_name_remove_projectfile_project_and_more.cpython-310.pyc new file mode 100644 index 00000000..1d3a1ca3 Binary files /dev/null and b/osinaweb/osinacore/migrations/__pycache__/0105_remove_projectfile_name_remove_projectfile_project_and_more.cpython-310.pyc differ diff --git a/osinaweb/osinacore/models.py b/osinaweb/osinacore/models.py index b0c031f9..2cc9bd80 100644 --- a/osinaweb/osinacore/models.py +++ b/osinaweb/osinacore/models.py @@ -291,17 +291,25 @@ class ProjectRequirement(models.Model): return self.content -class ProjectFile(models.Model): - name = models.CharField(max_length=350) - file = models.FileField(upload_to='uploaded_images', blank=True) - date = models.DateField() +class ProjectFileAlbum(models.Model): + name = models.CharField(max_length=350, null=True) project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True) + + +class ProjectFile(models.Model): + album = models.ForeignKey(ProjectFileAlbum, on_delete=models.CASCADE, null=True) + file = models.FileField(null=True) + date_added = models.DateTimeField(null=True) + + + class ProjectCredential(models.Model): - emailorusername = models.CharField(max_length=350) + identifier = models.CharField(max_length=350) password = models.CharField(max_length=350) - usedfor = models.CharField(max_length=350) + description = models.TextField(null=True, blank=True) project = models.ForeignKey(Project, on_delete=models.CASCADE, null=True) + date_added = models.DateTimeField(null=True) class Note(models.Model): diff --git a/osinaweb/osinacore/templates/add_templates/add-credentials-modal.html b/osinaweb/osinacore/templates/add_templates/add-credential-modal.html similarity index 65% rename from osinaweb/osinacore/templates/add_templates/add-credentials-modal.html rename to osinaweb/osinacore/templates/add_templates/add-credential-modal.html index 6a9d8a52..89ccc7f2 100644 --- a/osinaweb/osinacore/templates/add_templates/add-credentials-modal.html +++ b/osinaweb/osinacore/templates/add_templates/add-credential-modal.html @@ -14,26 +14,27 @@ -
+
+ {% csrf_token %}

Add Credential

- +
- +
- +
-
+ \ No newline at end of file diff --git a/osinaweb/osinacore/templates/add_templates/add-file-modal.html b/osinaweb/osinacore/templates/add_templates/add-file-modal.html index f42f834e..6844e722 100644 --- a/osinaweb/osinacore/templates/add_templates/add-file-modal.html +++ b/osinaweb/osinacore/templates/add_templates/add-file-modal.html @@ -17,19 +17,16 @@

Add File

-
+ + {% csrf_token %}
-
- -
- + Upload Document(s)