Skip to content

Commit 2b63dce

Browse files
Control the visibility of attributes (#86)
* New column for visibility of the attributes * Field visibility added on mutation * Adds field visibility to project im/export * Submodules change Co-authored-by: SirDeGraf <[email protected]>
1 parent de9afaa commit 2b63dce

File tree

5 files changed

+42
-2
lines changed

5 files changed

+42
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Add column for attribute visibility
2+
3+
Revision ID: da902ad27b4a
4+
Revises: f803a0c4343c
5+
Create Date: 2022-12-02 09:36:36.431815
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "da902ad27b4a"
14+
down_revision = "f803a0c4343c"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.add_column("attribute", sa.Column("visibility", sa.String(), nullable=True))
22+
# ### end Alembic commands ###
23+
24+
25+
def downgrade():
26+
# ### commands auto generated by Alembic - please adjust! ###
27+
op.drop_column("attribute", "visibility")
28+
# ### end Alembic commands ###

controller/attribute/manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ def update_attribute(
8888
is_primary_key: bool,
8989
name: str,
9090
source_code: str,
91+
visibility: str,
9192
) -> None:
9293

9394
attribute_item: Attribute = attribute.update(
@@ -98,6 +99,7 @@ def update_attribute(
9899
name,
99100
source_code,
100101
with_commit=True,
102+
visibility=visibility,
101103
)
102104

103105
notification.send_organization_update(

controller/transfer/project_transfer_manager.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ def import_file(
208208
source_code=attribute_item.get(
209209
"source_code",
210210
),
211+
visibility=attribute_item.get("visibility"),
211212
project_id=project_id,
212213
)
213214
attribute_ids_by_old_id[
@@ -984,6 +985,7 @@ def get_project_export_dump(
984985
"source_code": attribute_item.source_code,
985986
"state": attribute_item.state,
986987
"logs": attribute_item.logs,
988+
"visibility": attribute_item.visibility,
987989
}
988990
for attribute_item in attributes
989991
]

graphql_api/mutation/attribute.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Arguments:
2828
is_primary_key = graphene.Boolean()
2929
name = graphene.String()
3030
source_code = graphene.String()
31+
visibility = graphene.String()
3132

3233
ok = graphene.Boolean()
3334

@@ -40,11 +41,18 @@ def mutate(
4041
is_primary_key: Optional[bool] = None,
4142
name: Optional[str] = None,
4243
source_code: Optional[str] = None,
44+
visibility: Optional[str] = None,
4345
):
4446
auth.check_demo_access(info)
4547
auth.check_project_access(info, project_id)
4648
manager.update_attribute(
47-
project_id, attribute_id, data_type, is_primary_key, name, source_code
49+
project_id,
50+
attribute_id,
51+
data_type,
52+
is_primary_key,
53+
name,
54+
source_code,
55+
visibility,
4856
)
4957
return UpdateAttribute(ok=True)
5058

submodules/model

0 commit comments

Comments
 (0)