Skip to content

Commit 31b677f

Browse files
authored
Merge pull request #515 from MicroPyramid/new_release
new release
2 parents a012225 + 6ee8231 commit 31b677f

File tree

8 files changed

+54
-37
lines changed

8 files changed

+54
-37
lines changed

accounts/urls.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
urlpatterns = [
88
path("", views.AccountsListView.as_view()),
9-
path("<int:pk>/", views.AccountDetailView.as_view()),
10-
path("<int:pk>/create_mail/", views.AccountCreateMailView.as_view()),
11-
path("comment/<int:pk>/", views.AccountCommentView.as_view()),
12-
path("attachment/<int:pk>/", views.AccountAttachmentView.as_view()),
9+
path("<str:pk>/", views.AccountDetailView.as_view()),
10+
path("<str:pk>/create_mail/", views.AccountCreateMailView.as_view()),
11+
path("comment/<str:pk>/", views.AccountCommentView.as_view()),
12+
path("attachment/<str:pk>/", views.AccountAttachmentView.as_view()),
1313
]

accounts/views.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
AccountCommentEditSwaggerSerializer,
2727
EmailWriteSerializer
2828
)
29+
from teams.serializer import TeamsSerializer
2930
from accounts.tasks import send_email, send_email_to_assigned_user
3031
from cases.serializer import CaseSerializer
3132
from common.models import Attachments, Comment, Profile
@@ -113,17 +114,28 @@ def get_context_data(self, **kwargs):
113114
offset = 0
114115
accounts_close = AccountSerializer(results_accounts_close, many=True).data
115116

117+
contacts = Contact.objects.filter(org=self.request.profile.org).values(
118+
"id", "first_name"
119+
)
120+
context["contacts"] = contacts
116121
context["closed_accounts"] = {
117122
"offset": offset,
118123
"close_accounts": accounts_close,
119124
}
125+
context["teams"] = TeamsSerializer(
126+
Teams.objects.filter(org=self.request.profile.org), many=True
127+
).data
128+
context["countries"] = COUNTRIES
120129
context["industries"] = INDCHOICES
121130

122131
tags = Tags.objects.all()
123132
tags = TagsSerailizer(tags, many=True).data
124133

125134
context["tags"] = tags
126-
135+
users = Profile.objects.filter(is_active=True, org=self.request.profile.org).values(
136+
"id", "user__email"
137+
)
138+
context["users"] = users
127139
return context
128140

129141
@extend_schema(tags=["Accounts"], parameters=swagger_params1.account_get_params)
@@ -386,6 +398,9 @@ def get(self, request, pk, format=None):
386398
"cases": CaseSerializer(
387399
self.account.accounts_cases.all(), many=True
388400
).data,
401+
"teams" : TeamsSerializer(
402+
Teams.objects.filter(org=self.request.profile.org), many=True
403+
).data,
389404
"stages": STAGES,
390405
"sources": SOURCES,
391406
"countries": COUNTRIES,

cases/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
path("", views.CaseListView.as_view()),
9-
path("<int:pk>/", views.CaseDetailView.as_view()),
10-
path("comment/<int:pk>/", views.CaseCommentView.as_view()),
11-
path("attachment/<int:pk>/", views.CaseAttachmentView.as_view()),
9+
path("<str:pk>/", views.CaseDetailView.as_view()),
10+
path("comment/<str:pk>/", views.CaseCommentView.as_view()),
11+
path("attachment/<str:pk>/", views.CaseAttachmentView.as_view()),
1212
]

common/middleware/get_company.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import jwt
22
from django.conf import settings
33
from django.contrib.auth import logout
4-
from django.core.exceptions import ValidationError
4+
from django.core.exceptions import ValidationError,PermissionDenied
55
from rest_framework import status
66
from rest_framework.response import Response
77
from crum import get_current_user
@@ -44,19 +44,21 @@ def __call__(self, request):
4444
return self.get_response(request)
4545

4646
def process_request(self, request):
47-
48-
request.profile = None
49-
user_id = None
50-
# here I am getting the the jwt token passing in header
51-
if request.headers.get("Authorization"):
52-
token1 = request.headers.get("Authorization")
53-
token = token1.split(" ")[1] # getting the token value
54-
decoded = jwt.decode(token, (settings.SECRET_KEY), algorithms=[settings.JWT_ALGO])
55-
user_id = decoded['user_id']
56-
if user_id is not None:
57-
if request.headers.get("org"):
58-
profile = Profile.objects.get(
59-
user_id=user_id, org=request.headers.get("org"), is_active=True
60-
)
61-
if profile:
62-
request.profile = profile
47+
try :
48+
request.profile = None
49+
user_id = None
50+
# here I am getting the the jwt token passing in header
51+
if request.headers.get("Authorization"):
52+
token1 = request.headers.get("Authorization")
53+
token = token1.split(" ")[1] # getting the token value
54+
decoded = jwt.decode(token, (settings.SECRET_KEY), algorithms=[settings.JWT_ALGO])
55+
user_id = decoded['user_id']
56+
if user_id is not None:
57+
if request.headers.get("org"):
58+
profile = Profile.objects.get(
59+
user_id=user_id, org=request.headers.get("org"), is_active=True
60+
)
61+
if profile:
62+
request.profile = profile
63+
except :
64+
raise PermissionDenied()

events/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
path("", views.EventListView.as_view()),
9-
path("<int:pk>/", views.EventDetailView.as_view()),
10-
path("comment/<int:pk>/", views.EventCommentView.as_view()),
11-
path("attachment/<int:pk>/", views.EventAttachmentView.as_view()),
9+
path("<str:pk>/", views.EventDetailView.as_view()),
10+
path("comment/<str:pk>/", views.EventCommentView.as_view()),
11+
path("attachment/<str:pk>/", views.EventAttachmentView.as_view()),
1212
]

invoices/api_urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
path("", api_views.InvoiceListView.as_view()),
9-
path("<int:pk>/", api_views.InvoiceDetailView.as_view()),
10-
path("comment/<int:pk>/", api_views.InvoiceCommentView.as_view()),
11-
path("attachment/<int:pk>/", api_views.InvoiceAttachmentView.as_view()),
9+
path("<str:pk>/", api_views.InvoiceDetailView.as_view()),
10+
path("comment/<str:pk>/", api_views.InvoiceCommentView.as_view()),
11+
path("attachment/<str:pk>/", api_views.InvoiceAttachmentView.as_view()),
1212
]

opportunity/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
path("", views.OpportunityListView.as_view()),
9-
path("<int:pk>/", views.OpportunityDetailView.as_view()),
10-
path("comment/<int:pk>/", views.OpportunityCommentView.as_view()),
11-
path("attachment/<int:pk>/", views.OpportunityAttachmentView.as_view()),
9+
path("<str:pk>/", views.OpportunityDetailView.as_view()),
10+
path("comment/<str:pk>/", views.OpportunityCommentView.as_view()),
11+
path("attachment/<str:pk>/", views.OpportunityAttachmentView.as_view()),
1212
]

tasks/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
urlpatterns = [
88
path("", views.TaskListView.as_view()),
9-
path("<int:pk>/", views.TaskDetailView.as_view()),
10-
path("comment/<int:pk>/", views.TaskCommentView.as_view()),
11-
path("attachment/<int:pk>/", views.TaskAttachmentView.as_view()),
9+
path("<str:pk>/", views.TaskDetailView.as_view()),
10+
path("comment/<str:pk>/", views.TaskCommentView.as_view()),
11+
path("attachment/<str:pk>/", views.TaskAttachmentView.as_view()),
1212
]

0 commit comments

Comments
 (0)