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

new release #515

Merged
merged 1 commit into from
Oct 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
8 changes: 4 additions & 4 deletions accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

urlpatterns = [
path("", views.AccountsListView.as_view()),
path("<int:pk>/", views.AccountDetailView.as_view()),
path("<int:pk>/create_mail/", views.AccountCreateMailView.as_view()),
path("comment/<int:pk>/", views.AccountCommentView.as_view()),
path("attachment/<int:pk>/", views.AccountAttachmentView.as_view()),
path("<str:pk>/", views.AccountDetailView.as_view()),
path("<str:pk>/create_mail/", views.AccountCreateMailView.as_view()),
path("comment/<str:pk>/", views.AccountCommentView.as_view()),
path("attachment/<str:pk>/", views.AccountAttachmentView.as_view()),
]
17 changes: 16 additions & 1 deletion accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
AccountCommentEditSwaggerSerializer,
EmailWriteSerializer
)
from teams.serializer import TeamsSerializer
from accounts.tasks import send_email, send_email_to_assigned_user
from cases.serializer import CaseSerializer
from common.models import Attachments, Comment, Profile
Expand Down Expand Up @@ -113,17 +114,28 @@ def get_context_data(self, **kwargs):
offset = 0
accounts_close = AccountSerializer(results_accounts_close, many=True).data

contacts = Contact.objects.filter(org=self.request.profile.org).values(
"id", "first_name"
)
context["contacts"] = contacts
context["closed_accounts"] = {
"offset": offset,
"close_accounts": accounts_close,
}
context["teams"] = TeamsSerializer(
Teams.objects.filter(org=self.request.profile.org), many=True
).data
context["countries"] = COUNTRIES
context["industries"] = INDCHOICES

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

context["tags"] = tags

users = Profile.objects.filter(is_active=True, org=self.request.profile.org).values(
"id", "user__email"
)
context["users"] = users
return context

@extend_schema(tags=["Accounts"], parameters=swagger_params1.account_get_params)
Expand Down Expand Up @@ -386,6 +398,9 @@ def get(self, request, pk, format=None):
"cases": CaseSerializer(
self.account.accounts_cases.all(), many=True
).data,
"teams" : TeamsSerializer(
Teams.objects.filter(org=self.request.profile.org), many=True
).data,
"stages": STAGES,
"sources": SOURCES,
"countries": COUNTRIES,
Expand Down
6 changes: 3 additions & 3 deletions cases/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

urlpatterns = [
path("", views.CaseListView.as_view()),
path("<int:pk>/", views.CaseDetailView.as_view()),
path("comment/<int:pk>/", views.CaseCommentView.as_view()),
path("attachment/<int:pk>/", views.CaseAttachmentView.as_view()),
path("<str:pk>/", views.CaseDetailView.as_view()),
path("comment/<str:pk>/", views.CaseCommentView.as_view()),
path("attachment/<str:pk>/", views.CaseAttachmentView.as_view()),
]
36 changes: 19 additions & 17 deletions common/middleware/get_company.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import jwt
from django.conf import settings
from django.contrib.auth import logout
from django.core.exceptions import ValidationError
from django.core.exceptions import ValidationError,PermissionDenied
from rest_framework import status
from rest_framework.response import Response
from crum import get_current_user
Expand Down Expand Up @@ -44,19 +44,21 @@ def __call__(self, request):
return self.get_response(request)

def process_request(self, request):

request.profile = None
user_id = None
# here I am getting the the jwt token passing in header
if request.headers.get("Authorization"):
token1 = request.headers.get("Authorization")
token = token1.split(" ")[1] # getting the token value
decoded = jwt.decode(token, (settings.SECRET_KEY), algorithms=[settings.JWT_ALGO])
user_id = decoded['user_id']
if user_id is not None:
if request.headers.get("org"):
profile = Profile.objects.get(
user_id=user_id, org=request.headers.get("org"), is_active=True
)
if profile:
request.profile = profile
try :
request.profile = None
user_id = None
# here I am getting the the jwt token passing in header
if request.headers.get("Authorization"):
token1 = request.headers.get("Authorization")
token = token1.split(" ")[1] # getting the token value
decoded = jwt.decode(token, (settings.SECRET_KEY), algorithms=[settings.JWT_ALGO])
user_id = decoded['user_id']
if user_id is not None:
if request.headers.get("org"):
profile = Profile.objects.get(
user_id=user_id, org=request.headers.get("org"), is_active=True
)
if profile:
request.profile = profile
except :
raise PermissionDenied()
6 changes: 3 additions & 3 deletions events/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

urlpatterns = [
path("", views.EventListView.as_view()),
path("<int:pk>/", views.EventDetailView.as_view()),
path("comment/<int:pk>/", views.EventCommentView.as_view()),
path("attachment/<int:pk>/", views.EventAttachmentView.as_view()),
path("<str:pk>/", views.EventDetailView.as_view()),
path("comment/<str:pk>/", views.EventCommentView.as_view()),
path("attachment/<str:pk>/", views.EventAttachmentView.as_view()),
]
6 changes: 3 additions & 3 deletions invoices/api_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

urlpatterns = [
path("", api_views.InvoiceListView.as_view()),
path("<int:pk>/", api_views.InvoiceDetailView.as_view()),
path("comment/<int:pk>/", api_views.InvoiceCommentView.as_view()),
path("attachment/<int:pk>/", api_views.InvoiceAttachmentView.as_view()),
path("<str:pk>/", api_views.InvoiceDetailView.as_view()),
path("comment/<str:pk>/", api_views.InvoiceCommentView.as_view()),
path("attachment/<str:pk>/", api_views.InvoiceAttachmentView.as_view()),
]
6 changes: 3 additions & 3 deletions opportunity/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

urlpatterns = [
path("", views.OpportunityListView.as_view()),
path("<int:pk>/", views.OpportunityDetailView.as_view()),
path("comment/<int:pk>/", views.OpportunityCommentView.as_view()),
path("attachment/<int:pk>/", views.OpportunityAttachmentView.as_view()),
path("<str:pk>/", views.OpportunityDetailView.as_view()),
path("comment/<str:pk>/", views.OpportunityCommentView.as_view()),
path("attachment/<str:pk>/", views.OpportunityAttachmentView.as_view()),
]
6 changes: 3 additions & 3 deletions tasks/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

urlpatterns = [
path("", views.TaskListView.as_view()),
path("<int:pk>/", views.TaskDetailView.as_view()),
path("comment/<int:pk>/", views.TaskCommentView.as_view()),
path("attachment/<int:pk>/", views.TaskAttachmentView.as_view()),
path("<str:pk>/", views.TaskDetailView.as_view()),
path("comment/<str:pk>/", views.TaskCommentView.as_view()),
path("attachment/<str:pk>/", views.TaskAttachmentView.as_view()),
]