Skip to content

Commit

Permalink
Add customer lab contact (#2595) (minor)
Browse files Browse the repository at this point in the history
### Added

- Column "lab_contact_id" to the Customer table.
  • Loading branch information
islean authored Oct 24, 2023
1 parent 19e55d2 commit fd87f19
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
34 changes: 34 additions & 0 deletions alembic/versions/db61c62d9bc0_add_customer_lab_contact.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
"""Add customer lab contact
Revision ID: db61c62d9bc0
Revises: e853d21feaa0
Create Date: 2023-10-05 12:53:28.435684
"""
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "db61c62d9bc0"
down_revision = "e853d21feaa0"
branch_labels = None
depends_on = None


def upgrade():
op.add_column(
table_name="customer",
column=sa.Column(
"lab_contact_id",
sa.INTEGER,
sa.ForeignKey(name="customer_lab_contact_fk_1", column="user.id"),
),
)


def downgrade():
op.drop_constraint(
constraint_name="customer_lab_contact_fk_1", table_name="customer", type_="foreignkey"
)
op.drop_column(table_name="customer", column_name="lab_contact_id")
2 changes: 2 additions & 0 deletions cg/server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ class CustomerView(BaseView):
"collaborations",
"comment",
"delivery_contact",
"lab_contact",
"loqus_upload",
"primary_contact",
"priority",
Expand All @@ -194,6 +195,7 @@ class CustomerView(BaseView):
"comment",
"delivery_contact",
"internal_id",
"lab_contact",
"name",
"primary_contact",
"priority",
Expand Down
2 changes: 2 additions & 0 deletions cg/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ class Customer(Model):
invoice_address = Column(types.Text, nullable=False)
invoice_reference = Column(types.String(32), nullable=False)
is_trusted = Column(types.Boolean, nullable=False, default=False)
lab_contact_id = Column(ForeignKey("user.id"))
lab_contact = orm.relationship("User", foreign_keys=[lab_contact_id])
loqus_upload = Column(types.Boolean, nullable=False, default=False)
name = Column(types.String(128), nullable=False)
organisation_number = Column(types.String(32))
Expand Down

0 comments on commit fd87f19

Please sign in to comment.