Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Instance Registration and Configuration #2793

Merged
merged 58 commits into from
Nov 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3bfbc3a
dev: remove default user
pablohashescobar Oct 30, 2023
5b2a1dd
dev: initiate licensing
pablohashescobar Oct 30, 2023
1fde71c
dev: remove migration file 0046
pablohashescobar Oct 30, 2023
b386842
feat: self hosted licensing initialize
pablohashescobar Oct 30, 2023
088615f
dev: instance licenses
pablohashescobar Oct 30, 2023
97b7a27
dev: change license response structure
pablohashescobar Oct 30, 2023
02a8caa
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 8, 2023
f34d508
dev: add default properties and issue mention migration
pablohashescobar Nov 8, 2023
ea54bbc
dev: reset migrations
pablohashescobar Nov 8, 2023
485e3e6
dev: instance configuration
pablohashescobar Nov 8, 2023
39f69b7
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 8, 2023
a4f28b3
dev: instance configuration migration
pablohashescobar Nov 8, 2023
66cb297
dev: update instance configuration model to take null and empty values
pablohashescobar Nov 8, 2023
3f78c1b
dev: instance configuration variables
pablohashescobar Nov 8, 2023
7eaf52b
dev: set default values
pablohashescobar Nov 8, 2023
f37bae9
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 8, 2023
b902185
dev: update instance configuration load
pablohashescobar Nov 8, 2023
589e29e
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 9, 2023
216f07f
dev: email configuration settings moved to database
pablohashescobar Nov 9, 2023
081e42c
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 9, 2023
4fdd6a0
dev: instance configuration on instance bootup
pablohashescobar Nov 13, 2023
efbf834
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 13, 2023
32a8133
dev: auto instance registration script
pablohashescobar Nov 14, 2023
aca0f5e
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 14, 2023
1eac8ea
dev: instance admin
pablohashescobar Nov 14, 2023
46f2663
dev: enable instance configuration and instance admin roles
pablohashescobar Nov 14, 2023
fea812f
dev: instance owner fix
pablohashescobar Nov 14, 2023
d05b63f
dev: instance configuration values
pablohashescobar Nov 14, 2023
ccfd1c7
dev: fix instance permissions and serializer
pablohashescobar Nov 14, 2023
095f647
dev: fix email senders
pablohashescobar Nov 14, 2023
5b2964d
fix: updating env config in case of db values are missing
sriramveeraghanta Nov 15, 2023
2aee627
dev: remove deprecated variables
pablohashescobar Nov 15, 2023
9789757
dev: fix current site domain registration
pablohashescobar Nov 15, 2023
89a5088
dev: update cors setup and local settings
pablohashescobar Nov 15, 2023
d9a06a5
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 15, 2023
1e9f4dd
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 15, 2023
deefdac
dev: migrate instance registration and configuration to manage commands
pablohashescobar Nov 15, 2023
6102de3
dev: check email validity
pablohashescobar Nov 15, 2023
55869ee
dev: update script to use manage command
pablohashescobar Nov 15, 2023
44a3097
dev: default bucket creation script
pablohashescobar Nov 16, 2023
ca79739
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 16, 2023
6045e65
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 16, 2023
95c35cd
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
sriramveeraghanta Nov 16, 2023
78d841d
dev: instance admin routes and initial set of screens
sriramveeraghanta Nov 16, 2023
c4d5ccd
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
sriramveeraghanta Nov 16, 2023
46e733a
dev: admin api to check if the current user is admin
pablohashescobar Nov 16, 2023
af5534f
Merge branch 'feat/self_hosted_instance' of github.com:makeplane/plan…
pablohashescobar Nov 16, 2023
29798fa
Merge branch 'dev/settings_configuration' of github.com:makeplane/pla…
pablohashescobar Nov 16, 2023
936535f
dev: instance admin unique constraints
pablohashescobar Nov 16, 2023
3f2b890
dev: check magic link login
pablohashescobar Nov 16, 2023
cc158ae
dev: fix email sending for ssl
pablohashescobar Nov 16, 2023
63d5951
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 16, 2023
a65da91
dev: create instance activation route if the instance is not activate…
pablohashescobar Nov 16, 2023
5afb71a
dev: removed DJANGO_SETTINGS_MODULE from environment files and delete…
pablohashescobar Nov 16, 2023
93aeb37
Merge branch 'develop' of github.com:makeplane/plane into feat/self_h…
pablohashescobar Nov 17, 2023
6531e42
dev: environment configuration for backend
pablohashescobar Nov 17, 2023
0bb1314
dev: fix access token variable error
pablohashescobar Nov 17, 2023
385d93a
feat: Instance Admin Panel: General Settings (#2792)
prateekshourya29 Nov 17, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dev: change license response structure
  • Loading branch information
pablohashescobar committed Oct 30, 2023
commit 97b7a2769555dc8a5135d047a9c411a7ad96ca55
1 change: 1 addition & 0 deletions apiserver/plane/license/api/serializers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .instance import InstanceSerializer
22 changes: 22 additions & 0 deletions apiserver/plane/license/api/serializers/instance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Module imports
from plane.license.models import Instance
from plane.api.serializers import BaseSerializer
from plane.api.serializers import UserAdminLiteSerializer


class InstanceSerializer(BaseSerializer):
user_details = UserAdminLiteSerializer(source="user", read_only=True)

class Meta:
model = Instance
fields = "__all__"
read_only_fields = [
"id",
"user",
"instance_id",
"license_key",
"api_key",
"version",
"email",
"last_checked_at",
]
2 changes: 1 addition & 1 deletion apiserver/plane/license/api/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .instance import InstanceEndpoint
from .instance import InstanceEndpoint, TransferOwnerEndpoint
66 changes: 58 additions & 8 deletions apiserver/plane/license/api/views/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,27 @@
# Third party imports
from rest_framework import status
from rest_framework.response import Response
from rest_framework.permissions import AllowAny
from rest_framework.permissions import AllowAny, IsAuthenticated

# Module imports
from plane.api.views import BaseAPIView
from plane.license.models import Instance
from plane.license.api.serializers import InstanceSerializer
from plane.db.models import User


class InstanceEndpoint(BaseAPIView):
permission_classes = [
AllowAny,
]
def get_permissions(self):
if self.request.method == "PATCH":
self.permission_classes = [
IsAuthenticated,
]
else:
self.permission_classes = [
AllowAny,
]

return super(InstanceEndpoint, self).get_permissions()

def post(self, request):
email = request.data.get("email", False)
Expand Down Expand Up @@ -85,9 +94,12 @@ def post(self, request):
user=user,
last_checked_at=timezone.now(),
)

serializer = InstanceSerializer(instance)

return Response(
{
"id": str(instance.instance_id),
"data": serializer.data,
"message": "Instance registered succesfully",
},
status=status.HTTP_200_OK,
Expand All @@ -97,10 +109,12 @@ def post(self, request):
{"error": "Unable to create instance"}, status=response.status_code
)

serializer = InstanceSerializer(instance)

return Response(
{
"message": "Instance is already registered",
"instance_id": str(instance.id),
"data": serializer.data,
},
status=status.HTTP_200_OK,
)
Expand All @@ -111,10 +125,46 @@ def get(self, request):
if instance is None:
return Response({"activated": False}, status=status.HTTP_400_BAD_REQUEST)

serializer = InstanceSerializer(instance)

data = {
"instance_id": instance.instance_id,
"version": instance.version,
"data": serializer.data,
"activated": True,
}

return Response(data, status=status.HTTP_200_OK)

def patch(self, request):
instance = Instance.objects.first()
serializer = InstanceSerializer(instance, data=request.data, partial=True)
if serializer.is_valid():
serializer.save()
return Response(serializer.data, status=status.HTTP_200_OK)
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)


class TransferOwnerEndpoint(BaseAPIView):
permission_classes = [
IsAuthenticated,
]

def post(self, request):
instance = Instance.objects.first()

if str(instance.user_id) != str(request.user.id):
return Response({"error": "Forbidden"}, status=status.HTTP_403_FORBIDDEN)

user_id = request.data.get("user_id", False)

if not user_id:
return Response(
{"error": "User is required"}, status=status.HTTP_400_BAD_REQUEST
)

user = User.objects.get(pk=user_id)

instance.user = user
instance.save()
return Response(
{"message": "Owner successfully updated"}, status=status.HTTP_200_OK
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.3 on 2023-10-30 14:22

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('license', '0002_instance_last_checked_at'),
]

operations = [
migrations.AddField(
model_name='instance',
name='is_support_required',
field=models.BooleanField(default=True),
),
migrations.AddField(
model_name='instance',
name='is_telemetry_enabled',
field=models.BooleanField(default=True),
),
]
2 changes: 2 additions & 0 deletions apiserver/plane/license/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class Instance(BaseModel):
related_name="instance_owner",
)
last_checked_at = models.DateTimeField()
is_telemetry_enabled = models.BooleanField(default=True)
is_support_required = models.BooleanField(default=True)

class Meta:
verbose_name = "Instance"
Expand Down
7 changes: 6 additions & 1 deletion apiserver/plane/license/urls.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
from django.urls import path

from plane.license.api.views import InstanceEndpoint
from plane.license.api.views import InstanceEndpoint, TransferOwnerEndpoint

urlpatterns = [
path(
"instances/",
InstanceEndpoint.as_view(),
name="instance",
),
path(
"instances/transfer-owner/",
TransferOwnerEndpoint.as_view(),
name="instance",
),
]