Skip to content

Commit 98c958c

Browse files
authored
Merge pull request #3 from PROCOLLAB-github/dev
Dev
2 parents fe2735c + 3cd0024 commit 98c958c

30 files changed

+535
-51
lines changed

.github/workflows/release-ci.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
name: 'Build and Deploy server'
23

34
on:
@@ -87,15 +88,15 @@ jobs:
8788
cache-to: type=gha,mode=max
8889
tags: ${{ steps.meta.outputs.tags }}
8990
labels: ${{ steps.meta.outputs.labels }}
90-
91+
9192
- name: run on server
9293
uses: garygrossgarten/github-action-ssh@release
9394
with:
9495
host: ${{ secrets.SERVER_HOST }}
9596
username: ${{ secrets.SERVER_USER }}
9697
password: ${{ secrets.SERVER_PASSWORD }}
9798
command: |
98-
cd /home/app/procollab-backend &&
99+
cd /home/app/procollab-backend
99100
docker-compose -f docker-compose.prod-ci.yml -p prod pull
100101
101102
rm -f .env &&
@@ -114,6 +115,7 @@ jobs:
114115
echo "EMAIL_HOST=${{ secrets.EMAIL_HOST }}" >> .env &&
115116
echo "EMAIL_PORT=${{ secrets.EMAIL_PORT }}" >> .env &&
116117
117-
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env &&
118+
echo "SENTRY_DSN=${{ secrets.SENTRY_DSN }}" >> .env
119+
120+
docker-compose -f docker-compose.prod-ci.yml -p prod up -d
118121
119-
docker-compose -f docker-compose.prod-ci.yml -p prod up -d

industries/permissions.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from rest_framework.permissions import BasePermission
2+
3+
from core.constants import SAFE_METHODS
4+
5+
6+
class IndustryPermission(BasePermission):
7+
"""
8+
Allows access to update only to staff users.
9+
"""
10+
11+
def has_permission(self, request, view) -> bool:
12+
if request.method in SAFE_METHODS or request.user and request.user.is_staff:
13+
return True
14+
return False
15+
16+
def has_object_permission(self, request, view, obj) -> bool:
17+
if request.method in SAFE_METHODS or request.user and request.user.is_staff:
18+
return True
19+
return False

industries/tests.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,6 @@ def _user_create(self):
103103
user_id = response.data["id"]
104104
user = CustomUser.objects.get(id=user_id)
105105
user.is_active = True
106+
user.is_staff = True
106107
user.save()
107108
return user

industries/views.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
from rest_framework import generics
22

3+
from core.permissions import IsStaffOrReadOnly
34
from industries.models import Industry
45
from industries.serializers import IndustrySerializer
56

67

78
class IndustryList(generics.ListCreateAPIView):
89
queryset = Industry.objects.all()
910
serializer_class = IndustrySerializer
10-
# TODO check permissions using JWT
11-
# permission_classes = [permissions.IsAuthenticatedOrReadOnly]
11+
permission_classes = [IsStaffOrReadOnly]
1212

1313

1414
class IndustryDetail(generics.RetrieveUpdateDestroyAPIView):
1515
queryset = Industry.objects.all()
1616
serializer_class = IndustrySerializer
17-
# TODO check permissions using JWT
18-
# permission_classes = [permissions.IsAuthenticatedOrReadOnly]
17+
permission_classes = [IsStaffOrReadOnly]

metrics/__init__.py

Whitespace-only changes.

metrics/admin.py

Whitespace-only changes.

metrics/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.apps import AppConfig
2+
3+
4+
class MetricsConfig(AppConfig):
5+
default_auto_field = "django.db.models.BigAutoField"
6+
name = "metrics"
7+
verbose_name = "Метрики"

metrics/migrations/__init__.py

Whitespace-only changes.

metrics/tests.py

Whitespace-only changes.

metrics/urls.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from django.urls import path
2+
3+
4+
from metrics.views import MetricsView
5+
6+
app_name = "metrics"
7+
8+
urlpatterns = [
9+
path("", MetricsView.as_view()),
10+
]

0 commit comments

Comments
 (0)