Skip to content

Commit

Permalink
Making projects private or public
Browse files Browse the repository at this point in the history
  • Loading branch information
LanternNassi committed Jul 18, 2024
1 parent 7b9c445 commit de032f7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions api_docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2529,6 +2529,8 @@ paths:
type: string
project_type:
type: string
is_public:
type: string
tags_add:
type: array
items:
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ def patch(self, project_id):
current_user_roles = get_jwt_claims()['roles']

project_schema = ProjectSchema(
only=("name", "description", "organisation", "project_type", "tags_add", "tags_remove"), partial=True)
only=("name", "description", "organisation", "project_type", "is_public","tags_add", "tags_remove"), partial=True)

project_data = request.get_json()

Expand Down
1 change: 1 addition & 0 deletions app/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Project(ModelMixin):
date_created = db.Column(db.DateTime, default=db.func.current_timestamp())
users = relationship('ProjectUser', back_populates='other_project')
followers = relationship('ProjectFollowers', back_populates='project')
is_public = db.Column(db.Boolean, default=True)
project_transactions = db.relationship(
'TransactionRecord', backref='project', lazy=True)
billing_invoices = db.relationship(
Expand Down
1 change: 1 addition & 0 deletions app/schemas/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class ProjectSchema(Schema):
admin_disabled = fields.Boolean(dump_only=True)
prometheus_url = fields.Method("get_prometheus_url", dump_only=True)
is_following = fields.Method("get_is_following", dump_only=True)
is_public = fields.Boolean()
tags = fields.Nested("TagsProjectsSchema", many=True, dump_only=True)
tags_add = fields.List(fields.String, load_only=True)
tags_remove = fields.List(fields.String, load_only=True)
Expand Down
28 changes: 28 additions & 0 deletions migrations/versions/1532e6c6c526_.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"""empty message
Revision ID: 1532e6c6c526
Revises: 824b7f125075
Create Date: 2024-07-18 14:06:18.242951
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '1532e6c6c526'
down_revision = '824b7f125075'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('project', sa.Column('is_public', sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('project', 'is_public')
# ### end Alembic commands ###

0 comments on commit de032f7

Please sign in to comment.