-
Notifications
You must be signed in to change notification settings - Fork 0
add: Contact entity type #896
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
3ad0432
Add: new CONTACT entity type and corresponding enum in constants and …
6c5ea40
Remove unnecessary session flush calls in contact object class migration
f019cb1
.
0b09be4
Update test for extended object class to include CONTACT entity type …
170a441
Fix test assertion for entity_type_names to ignore type checking
13d0658
Refactor: remove object class creation and deletion logic from contac…
740f29e
Rename test function for clarity: updated test_get_one_extended_objec…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
82 changes: 82 additions & 0 deletions
82
app/alembic/versions/c5a9b3f2e8d7_add_contact_object_class.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| """Add Contact objectClass and mailRecipient to LDAP schema. | ||
|
|
||
| Revision ID: c5a9b3f2e8d7 | ||
| Revises: 8164b4a9e1f1, f1abf7ef2443 | ||
| Create Date: 2026-01-19 12:00:00.000000 | ||
|
|
||
| """ | ||
|
|
||
| from alembic import op | ||
| from dishka import AsyncContainer, Scope | ||
| from sqlalchemy import delete | ||
| from sqlalchemy.ext.asyncio import AsyncConnection, AsyncSession | ||
|
|
||
| from entities import EntityType | ||
| from enums import EntityTypeNames | ||
| from ldap_protocol.ldap_schema.dto import EntityTypeDTO | ||
| from ldap_protocol.ldap_schema.entity_type_use_case import EntityTypeUseCase | ||
| from ldap_protocol.utils.queries import get_base_directories | ||
| from repo.pg.tables import queryable_attr as qa | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "c5a9b3f2e8d7" | ||
| down_revision = "71e642808369" | ||
| branch_labels: None | str = None | ||
| depends_on: None | str = None | ||
|
|
||
|
|
||
| def upgrade(container: AsyncContainer) -> None: | ||
| """Add Contact objectClass and mailRecipient to LDAP schema.""" | ||
|
|
||
| async def _create_entity_type( | ||
| connection: AsyncConnection, # noqa: ARG001 | ||
| ) -> None: | ||
| """Create Contact Entity Type.""" | ||
| async with container(scope=Scope.REQUEST) as cnt: | ||
| session = await cnt.get(AsyncSession) | ||
| entity_type_use_case = await cnt.get(EntityTypeUseCase) | ||
|
|
||
| if not await get_base_directories(session): | ||
| return | ||
|
|
||
| await entity_type_use_case.create( | ||
| EntityTypeDTO( | ||
| name=EntityTypeNames.CONTACT, | ||
| object_class_names=[ | ||
| "top", | ||
| "person", | ||
| "organizationalPerson", | ||
| "contact", | ||
| "mailRecipient", | ||
| ], | ||
| is_system=True, | ||
| ), | ||
| ) | ||
|
|
||
| await session.commit() | ||
|
|
||
| op.run_async(_create_entity_type) | ||
|
|
||
|
|
||
| def downgrade(container: AsyncContainer) -> None: | ||
| """Remove Contact objectClass and mailRecipient from LDAP schema.""" | ||
|
|
||
| async def _delete_entity_type( | ||
| connection: AsyncConnection, # noqa: ARG001 | ||
| ) -> None: | ||
| """Delete Contact Entity Type.""" | ||
| async with container(scope=Scope.REQUEST) as cnt: | ||
| session = await cnt.get(AsyncSession) | ||
|
|
||
| if not await get_base_directories(session): | ||
| return | ||
|
|
||
| await session.execute( | ||
| delete(EntityType).where( | ||
| qa(EntityType.name) == EntityTypeNames.CONTACT, | ||
| ), | ||
| ) | ||
|
|
||
| await session.commit() | ||
|
|
||
| op.run_async(_delete_entity_type) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule interface
updated
from 97bbc0 to f31962
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
название теста тогда поменяй, уже не test_get_one