-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix-create-invitations
- Loading branch information
Showing
90 changed files
with
4,409 additions
and
1,158 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,3 +58,6 @@ pyjwt | |
cryptography | ||
|
||
Pillow | ||
|
||
# fiona | ||
fiona==1.10.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
django_project/analysis/migrations/0004_useranalysisresults.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.15 on 2025-01-22 07:02 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('analysis', '0003_alter_landscape_options_landscape_project_name_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='UserAnalysisResults', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('analysis_results', models.JSONField()), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('source', models.CharField(blank=True, max_length=255, null=True)), | ||
('created_by', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
26 changes: 26 additions & 0 deletions
26
...o_project/analysis/migrations/0005_alter_useranalysisresults_analysis_results_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 4.2.15 on 2025-01-22 07:34 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('analysis', '0004_useranalysisresults'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='useranalysisresults', | ||
name='analysis_results', | ||
field=models.JSONField(blank=True, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='useranalysisresults', | ||
name='created_by', | ||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from rest_framework import serializers | ||
from .models import UserAnalysisResults | ||
|
||
|
||
class UserAnalysisResultsSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = UserAnalysisResults | ||
fields = [ | ||
'id', | ||
'created_by', | ||
'analysis_results', | ||
'created_at', | ||
'source' | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from django.urls import path, include | ||
from rest_framework.routers import DefaultRouter | ||
from .views import UserAnalysisResultsViewSet | ||
|
||
router = DefaultRouter() | ||
router.register(r'user_analysis_results', UserAnalysisResultsViewSet) | ||
|
||
urlpatterns = [ | ||
path('', include(router.urls)), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,34 @@ | ||
from django.shortcuts import render # noqa: F401 | ||
from rest_framework import viewsets | ||
from .models import UserAnalysisResults | ||
from .serializer import UserAnalysisResultsSerializer | ||
from rest_framework.response import Response | ||
from rest_framework.permissions import IsAuthenticated | ||
from rest_framework.decorators import action | ||
|
||
# Create your views here. | ||
|
||
class UserAnalysisResultsViewSet(viewsets.ModelViewSet): | ||
queryset = UserAnalysisResults.objects.all() | ||
serializer_class = UserAnalysisResultsSerializer | ||
permission_classes = [IsAuthenticated] | ||
|
||
def perform_create(self, serializer): | ||
serializer.save( | ||
created_by=self.request.user, | ||
analysis_results=self.request.data.get('analysis_results') | ||
) | ||
|
||
@action(detail=False, methods=['get']) | ||
def fetch_analysis_results(self, request): | ||
analysis_results = UserAnalysisResults.objects.filter( | ||
created_by=request.user | ||
) | ||
serializer = self.get_serializer(analysis_results, many=True) | ||
return Response(serializer.data) | ||
|
||
@action(detail=False, methods=['post']) | ||
def save_analysis_results(self, request): | ||
serializer = self.get_serializer(data=request.data) | ||
if serializer.is_valid(): | ||
serializer.save(created_by=request.user) | ||
return Response(serializer.data, status=201) | ||
return Response(serializer.errors, status=400) |
Oops, something went wrong.