Skip to content

Commit

Permalink
[WEB - 1408] dev: add logo prop and accounts migration (#4558)
Browse files Browse the repository at this point in the history
* dev: add logo prop and accounts migration

* dev: add default values for id_token

* dev: update is_active as read only field

* dev: delete all sessions when deactivating account

* dev: add issue description binary

* dev: add logo props for team
  • Loading branch information
pablohashescobar authored May 23, 2024
1 parent 6a3c4eb commit b574328
Show file tree
Hide file tree
Showing 14 changed files with 85 additions and 4 deletions.
1 change: 1 addition & 0 deletions apiserver/plane/app/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Meta:
"is_bot",
"is_password_autoset",
"is_email_verified",
"is_active",
]
extra_kwargs = {"password": {"write_only": True}}

Expand Down
16 changes: 13 additions & 3 deletions apiserver/plane/app/views/user/base.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Python imports
# import uuid

# Django imports
from django.db.models import Case, Count, IntegerField, Q, When
from django.contrib.auth import logout
Expand Down Expand Up @@ -26,6 +29,7 @@
User,
WorkspaceMember,
WorkspaceMemberInvite,
Session,
)
from plane.license.models import Instance, InstanceAdmin
from plane.utils.cache import cache_response, invalidate_cache
Expand Down Expand Up @@ -160,12 +164,13 @@ def deactivate(self, request):
email=user.email,
).delete()

# Deactivate the user
user.is_active = False
# Delete all sessions
Session.objects.filter(user_id=request.user.id).delete()

# Profile updates
profile = Profile.objects.get(user=user)

# Reset onboarding
profile.last_workspace_id = None
profile.is_tour_completed = False
profile.is_onboarded = False
Expand All @@ -177,7 +182,12 @@ def deactivate(self, request):
}
profile.save()

# User log out
# Reset password
# user.is_password_autoset = True
# user.set_password(uuid.uuid4().hex)

# Deactivate the user
user.is_active = False
user.last_logout_ip = user_ip(request=request)
user.last_logout_time = timezone.now()
user.save()
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/authentication/adapter/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,6 @@ def create_update_account(self, user):
"refresh_token_expired_at"
),
"last_connected_at": timezone.now(),
"id_token": self.token_data.get("id_token", ""),
},
)
1 change: 1 addition & 0 deletions apiserver/plane/authentication/provider/oauth/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def set_token_data(self):
if token_response.get("refresh_token_expired_at")
else None
),
"id_token": token_response.get("id_token", ""),
}
)

Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/authentication/provider/oauth/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def set_token_data(self):
if token_response.get("refresh_token_expired_at")
else None
),
"id_token": token_response.get("id_token", ""),
}
)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Generated by Django 4.2.11 on 2024-05-22 15:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("db", "0065_auto_20240415_0937"),
]

operations = [
migrations.AddField(
model_name="account",
name="id_token",
field=models.TextField(blank=True),
),
migrations.AddField(
model_name="cycle",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="module",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="issueview",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="inbox",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="dashboard",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="widget",
name="logo_props",
field=models.JSONField(default=dict),
),
migrations.AddField(
model_name="issue",
name="description_binary",
field=models.BinaryField(null=True),
),
migrations.AddField(
model_name="team",
name="logo_props",
field=models.JSONField(default=dict),
),
]
1 change: 1 addition & 0 deletions apiserver/plane/db/models/cycle.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class Cycle(ProjectBaseModel):
external_id = models.CharField(max_length=255, blank=True, null=True)
progress_snapshot = models.JSONField(default=dict)
archived_at = models.DateTimeField(null=True)
logo_props = models.JSONField(default=dict)

class Meta:
verbose_name = "Cycle"
Expand Down
2 changes: 2 additions & 0 deletions apiserver/plane/db/models/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Dashboard(BaseModel):
verbose_name="Dashboard Type",
default="home",
)
logo_props = models.JSONField(default=dict)

def __str__(self):
"""Return name of the dashboard"""
Expand All @@ -53,6 +54,7 @@ class Widget(TimeAuditModel):
)
key = models.CharField(max_length=255)
filters = models.JSONField(default=dict)
logo_props = models.JSONField(default=dict)

def __str__(self):
"""Return name of the widget"""
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/db/models/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Inbox(ProjectBaseModel):
)
is_default = models.BooleanField(default=False)
view_props = models.JSONField(default=dict)
logo_props = models.JSONField(default=dict)

def __str__(self):
"""Return name of the Inbox"""
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/db/models/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Issue(ProjectBaseModel):
description = models.JSONField(blank=True, default=dict)
description_html = models.TextField(blank=True, default="<p></p>")
description_stripped = models.TextField(blank=True, null=True)
description_binary = models.BinaryField(null=True)
priority = models.CharField(
max_length=30,
choices=PRIORITY_CHOICES,
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/db/models/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class Module(ProjectBaseModel):
external_source = models.CharField(max_length=255, null=True, blank=True)
external_id = models.CharField(max_length=255, blank=True, null=True)
archived_at = models.DateTimeField(null=True)
logo_props = models.JSONField(default=dict)

class Meta:
unique_together = ["name", "project"]
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/db/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ class Account(TimeAuditModel):
refresh_token = models.TextField(null=True, blank=True)
refresh_token_expired_at = models.DateTimeField(null=True)
last_connected_at = models.DateTimeField(default=timezone.now)
id_token = models.TextField(blank=True)
metadata = models.JSONField(default=dict)

class Meta:
Expand Down
3 changes: 2 additions & 1 deletion apiserver/plane/db/models/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def get_default_display_properties():
}


# DEPRECATED TODO: - Remove in next release
class GlobalView(BaseModel):
workspace = models.ForeignKey(
"db.Workspace", on_delete=models.CASCADE, related_name="global_views"
Expand Down Expand Up @@ -87,7 +88,6 @@ def __str__(self):
return f"{self.name} <{self.workspace.name}>"


# DEPRECATED TODO: - Remove in next release
class IssueView(WorkspaceBaseModel):
name = models.CharField(max_length=255, verbose_name="View Name")
description = models.TextField(verbose_name="View Description", blank=True)
Expand All @@ -101,6 +101,7 @@ class IssueView(WorkspaceBaseModel):
default=1, choices=((0, "Private"), (1, "Public"))
)
sort_order = models.FloatField(default=65535)
logo_props = models.JSONField(default=dict)

class Meta:
verbose_name = "Issue View"
Expand Down
1 change: 1 addition & 0 deletions apiserver/plane/db/models/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class Team(BaseModel):
workspace = models.ForeignKey(
Workspace, on_delete=models.CASCADE, related_name="workspace_team"
)
logo_props = models.JSONField(default=dict)

def __str__(self):
"""Return name of the team"""
Expand Down

0 comments on commit b574328

Please sign in to comment.