~homeworkprod/byceps

9f9e7abd1a07b6d61a6f083d62fadb3eec563900 — Jochen Kupperschmidt 1 year, 2 months ago 6f43df3
Rework retrieval of user's orga team to show on public profile
M byceps/blueprints/user/profile/templates/user/profile/view.html => byceps/blueprints/user/profile/templates/user/profile/view.html +2 -2
@@ 29,8 29,8 @@
          {{ render_user_screen_name(user) }}
        </div>
        <div class="user-profile-header-cell-bottom orgateam">
          {%- if orga_team_membership %}
          {{ orga_team_membership.orga_team.title }}
          {%- if orga_team %}
          {{ orga_team.title }}
          {%- endif %}
        </div>
      </div>

M byceps/blueprints/user/profile/views.py => byceps/blueprints/user/profile/views.py +2 -2
@@ 33,7 33,7 @@ def view(user_id):
        user.id
    )

    orga_team_membership = orga_team_service.find_membership_for_party(
    orga_team = orga_team_service.find_orga_team_for_user_and_party(
        user.id, g.party_id
    )



@@ 48,7 48,7 @@ def view(user_id):
    return {
        'user': user,
        'badges_with_awarding_quantity': badges_with_awarding_quantity,
        'orga_team_membership': orga_team_membership,
        'orga_team': orga_team,
        'current_party_tickets': current_party_tickets,
        'attended_parties': attended_parties,
    }

M byceps/services/orga_team/service.py => byceps/services/orga_team/service.py +6 -5
@@ 167,15 167,16 @@ def _find_db_membership(membership_id: MembershipID) -> Optional[DbMembership]:
    return DbMembership.query.get(membership_id)


def find_membership_for_party(
def find_orga_team_for_user_and_party(
    user_id: UserID, party_id: PartyID
) -> Optional[DbMembership]:
) -> Optional[OrgaTeam]:
    """Return the user's membership in an orga team of that party, or
    `None` of user it not part of an orga team for that party.
    """
    return DbMembership.query \
        .filter_by(user_id=user_id) \
        .for_party(party_id) \
    return DbOrgaTeam.query \
        .join(DbMembership) \
        .filter(DbMembership.user_id == user_id) \
        .filter(DbOrgaTeam.party_id == party_id) \
        .one_or_none()