diff --git a/backend/alembic/versions/006_add_member_contact_fields.py b/backend/alembic/versions/006_add_member_contact_fields.py new file mode 100644 index 0000000..a727c84 --- /dev/null +++ b/backend/alembic/versions/006_add_member_contact_fields.py @@ -0,0 +1,44 @@ +"""Add contact fields to committee members + +Revision ID: 006 +Revises: 005 +Create Date: 2026-02-10 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '006' +down_revision = '005' +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # Make email and organization NOT NULL + op.alter_column('committee_members', 'email', + existing_type=sa.String(200), + nullable=False) + op.alter_column('committee_members', 'organization', + existing_type=sa.String(200), + nullable=False) + + # Add new optional contact fields + op.add_column('committee_members', sa.Column('gitcode_id', sa.String(100), nullable=True)) + op.add_column('committee_members', sa.Column('github_id', sa.String(100), nullable=True)) + + +def downgrade() -> None: + # Remove new fields + op.drop_column('committee_members', 'github_id') + op.drop_column('committee_members', 'gitcode_id') + + # Revert email and organization to nullable + op.alter_column('committee_members', 'organization', + existing_type=sa.String(200), + nullable=True) + op.alter_column('committee_members', 'email', + existing_type=sa.String(200), + nullable=True) diff --git a/backend/app/api/auth.py b/backend/app/api/auth.py index 64799a8..34d2d62 100644 --- a/backend/app/api/auth.py +++ b/backend/app/api/auth.py @@ -202,10 +202,17 @@ def get_current_user_info( """ from app.core.dependencies import get_user_community_role from app.schemas.community import CommunityWithRole - + from app.models.community import Community + + # Superusers can see all communities + if current_user.is_superuser: + communities = db.query(Community).all() + else: + communities = current_user.communities + # Build communities with roles communities_with_roles = [] - for community in current_user.communities: + for community in communities: role = get_user_community_role(current_user, community.id, db) communities_with_roles.append( CommunityWithRole( diff --git a/backend/app/models/committee.py b/backend/app/models/committee.py index b20497b..df8ebaf 100644 --- a/backend/app/models/committee.py +++ b/backend/app/models/committee.py @@ -65,10 +65,12 @@ class CommitteeMember(Base): ) name = Column(String(200), nullable=False) - email = Column(String(200), nullable=True, index=True) + email = Column(String(200), nullable=False, index=True) phone = Column(String(50), nullable=True) wechat = Column(String(100), nullable=True) - organization = Column(String(200), nullable=True) + organization = Column(String(200), nullable=False) + gitcode_id = Column(String(100), nullable=True) + github_id = Column(String(100), nullable=True) # 角色标签(中文,可多选,JSON数组) # 可选值: ["主席", "副主席", "委员", "常务委员"] diff --git a/backend/app/schemas/governance.py b/backend/app/schemas/governance.py index 41cdecf..a82a479 100644 --- a/backend/app/schemas/governance.py +++ b/backend/app/schemas/governance.py @@ -58,10 +58,12 @@ class CommitteeBrief(BaseModel): class CommitteeMemberCreate(BaseModel): name: str = Field(..., min_length=1, max_length=200) - email: Optional[str] = None + email: str = Field(..., min_length=1, max_length=200) phone: Optional[str] = None wechat: Optional[str] = None - organization: Optional[str] = None + organization: str = Field(..., min_length=1, max_length=200) + gitcode_id: Optional[str] = None + github_id: Optional[str] = None roles: list[str] = [] term_start: Optional[date] = None term_end: Optional[date] = None @@ -70,10 +72,12 @@ class CommitteeMemberCreate(BaseModel): class CommitteeMemberUpdate(BaseModel): name: Optional[str] = Field(None, min_length=1, max_length=200) - email: Optional[str] = None + email: Optional[str] = Field(None, min_length=1, max_length=200) phone: Optional[str] = None wechat: Optional[str] = None - organization: Optional[str] = None + organization: Optional[str] = Field(None, min_length=1, max_length=200) + gitcode_id: Optional[str] = None + github_id: Optional[str] = None roles: Optional[list[str]] = None term_start: Optional[date] = None term_end: Optional[date] = None @@ -86,10 +90,12 @@ class CommitteeMemberOut(BaseModel): id: int committee_id: int name: str - email: Optional[str] = None + email: str phone: Optional[str] = None wechat: Optional[str] = None - organization: Optional[str] = None + organization: str + gitcode_id: Optional[str] = None + github_id: Optional[str] = None roles: list[str] = [] term_start: Optional[date] = None term_end: Optional[date] = None diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 3e93d5c..1b1db19 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -18,10 +18,6 @@ text-color="#bbb" active-text-color="#409eff" > - - - 仪表板 - 社区总览 @@ -66,10 +62,6 @@ 批量管理 - - - 渠道设置 - 社区管理 @@ -78,11 +70,15 @@ 用户管理 + + + 仪表板 + - +