Skip to content

Commit

Permalink
Merge branch 'release-1.0.0' into fix/hamed-email-formatting-1930
Browse files Browse the repository at this point in the history
  • Loading branch information
hamed-valiollahi authored Feb 21, 2025
2 parents 395ce32 + 5d41c28 commit fee6b6e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
21 changes: 8 additions & 13 deletions backend/lcfs/web/api/allocation_agreement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
allocation agreements endpoints
"""

import structlog
from typing import List, Optional, Union
from typing import List, Optional

import structlog
from fastapi import (
APIRouter,
Body,
Expand All @@ -15,26 +15,24 @@
Depends,
Query,
)
from fastapi_cache.decorator import cache

from lcfs.db import dependencies
from lcfs.web.api.compliance_report.validation import ComplianceReportValidation
from lcfs.web.core.decorators import view_handler
from lcfs.web.api.organizations.services import OrganizationsService
from lcfs.web.api.allocation_agreement.services import AllocationAgreementServices
from lcfs.db.models.user.Role import RoleEnum
from lcfs.web.api.allocation_agreement.schema import (
AllocationAgreementCreateSchema,
AllocationAgreementOptionsSchema,
AllocationAgreementSchema,
AllocationAgreementListSchema,
DeleteAllocationAgreementResponseSchema,
PaginatedAllocationAgreementRequestSchema,
AllocationAgreementAllSchema,
OrganizationDetailsSchema,
)
from lcfs.web.api.base import ComplianceReportRequestSchema, PaginationRequestSchema
from lcfs.web.api.allocation_agreement.services import AllocationAgreementServices
from lcfs.web.api.allocation_agreement.validation import AllocationAgreementValidation
from lcfs.db.models.user.Role import RoleEnum
from lcfs.web.api.base import ComplianceReportRequestSchema, PaginationRequestSchema
from lcfs.web.api.compliance_report.validation import ComplianceReportValidation
from lcfs.web.api.organizations.services import OrganizationsService
from lcfs.web.core.decorators import view_handler

router = APIRouter()
logger = structlog.get_logger(__name__)
Expand Down Expand Up @@ -134,9 +132,6 @@ async def get_allocation_agreements_paginated(

@router.post(
"/save",
response_model=Union[
AllocationAgreementSchema, DeleteAllocationAgreementResponseSchema
],
status_code=status.HTTP_200_OK,
)
@view_handler([RoleEnum.COMPLIANCE_REPORTING, RoleEnum.SIGNING_AUTHORITY])
Expand Down
15 changes: 11 additions & 4 deletions backend/lcfs/web/api/transfer/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,17 @@ async def get_all_transfers(self) -> List[TransferSchema]:
async def get_transfer(self, transfer_id: int) -> TransferSchema:
"""Fetches a single transfer by its ID and converts it to a Pydantic model."""
transfer = await self.repo.get_transfer_by_id(transfer_id)
if not transfer:
# Check if the current viewer is a gov user
is_government_viewer = user_has_roles(self.request.user, [RoleEnum.GOVERNMENT])
if not transfer or (
is_government_viewer
and transfer.current_status.status
in [
TransferStatusEnum.Draft,
TransferStatusEnum.Sent,
TransferStatusEnum.Rescinded,
]
):
raise DataNotFoundException(f"Transfer with ID {transfer_id} not found")

transfer_view = TransferSchema.model_validate(transfer)
Expand All @@ -101,9 +111,6 @@ async def get_transfer(self, transfer_id: int) -> TransferSchema:
transfer.transfer_comments, key=lambda c: c.create_date
)

# Check if the current viewer is a gov user
is_government_viewer = user_has_roles(self.request.user, [RoleEnum.GOVERNMENT])

# Build the final list of comment schemas
final_comments = []
for c in sorted_comments:
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/BCDataGrid/BCGridEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,12 +200,12 @@ export const BCGridEditor = ({
const onCellFocused = (params) => {
if (params.column) {
// Ensure the focused column is always visible
this.gridApi.ensureColumnVisible(params.column)
params.gridApi.ensureColumnVisible(params.column)

// Scroll to make focused cell align to left
const leftPos = params.column.getLeftPosition()
if (leftPos !== null) {
this.gridApi.horizontalScrollTo(leftPos)
params.gridApi.horizontalScrollTo(leftPos)
}
}
}
Expand Down
14 changes: 9 additions & 5 deletions frontend/src/views/Admin/AdminMenu/components/ViewUser.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,15 @@ export const ViewUser = () => {
id="user-card"
title={t('admin:userDetails')}
color="nav"
editButton={{
text: canEdit ? t('admin:editBtn') : null,
route: canEdit ? editButtonRoute : null,
id: 'edit-user-button'
}}
editButton={
canEdit
? {
text: t('admin:editBtn'),
route: editButtonRoute,
id: 'edit-user-button'
}
: null
}
content={
<BCBox p={1}>
<BCBox
Expand Down

0 comments on commit fee6b6e

Please sign in to comment.