~homeworkprod/byceps

7f024cc37b606c59ea45514066030d89875d27b6 — Jochen Kupperschmidt 4 years ago 0dc8279
Access the current brand's ID via `g.party.brand_id` instead of
`g.party.brand.id`
M byceps/blueprints/authentication/views.py => byceps/blueprints/authentication/views.py +4 -2
@@ 147,12 147,14 @@ def login():
            abort(403)

    if not in_admin_mode:
        terms_version = terms_service.get_current_version(g.party.brand.id)
        brand_id = g.party.brand_id

        terms_version = terms_service.get_current_version(brand_id)

        if not terms_version:
            raise Exception(
                'No terms of service defined for brand "{}", denying login.'
                .format(g.party.brand.id))
                .format(brand_id))

        if not terms_service.has_user_accepted_version(user.id, terms_version.id):
            verification_token = verification_token_service \

M byceps/blueprints/board/views.py => byceps/blueprints/board/views.py +12 -6
@@ 47,7 47,8 @@ blueprint.add_app_template_filter(render_html, 'bbcode')
@templated
def category_index():
    """List categories."""
    brand_id = g.party.brand.id
    brand_id = g.party.brand_id

    categories = board_category_service.get_categories_with_last_updates(brand_id)

    return {


@@ 60,8 61,9 @@ def category_index():
@templated
def category_view(slug, page):
    """List latest topics in the category."""
    category = board_category_service.find_category_by_slug(g.party.brand.id,
                                                            slug)
    brand_id = g.party.brand_id

    category = board_category_service.find_category_by_slug(brand_id, slug)
    if category is None:
        abort(404)



@@ 129,11 131,13 @@ def topic_view(topic_id, page):

    is_last_page = not postings.has_next

    brand_id = g.party.brand_id

    creator_ids = {posting.creator_id for posting in postings.items}
    badges_by_user_id = badge_service.get_badges_for_users(creator_ids,
                                                           featured_only=True)
    badges_by_user_id = _select_global_and_brand_badges(badges_by_user_id,
                                                        g.party.brand.id)
                                                        brand_id)

    context = {
        'topic': topic,


@@ 278,8 282,10 @@ def topic_moderate_form(topic_id):
    """Show a form to moderate the topic."""
    topic = _get_topic_or_404(topic_id)

    categories = board_category_service.get_categories_excluding(
        g.party.brand.id, topic.category_id)
    brand_id = g.party.brand_id

    categories = board_category_service.get_categories_excluding(brand_id,
        topic.category_id)

    return {
        'topic': topic,

M byceps/blueprints/news/views.py => byceps/blueprints/news/views.py +5 -3
@@ 21,10 21,10 @@ blueprint = create_blueprint('news', __name__)
@templated
def index(page):
    """Show a page of news items."""
    brand_id = g.party.brand_id
    items_per_page = _get_items_per_page_value()

    items = news_service.get_items_paginated(g.party.brand.id, page,
                                             items_per_page)
    items = news_service.get_items_paginated(brand_id, page, items_per_page)

    return {
        'items': items,


@@ 36,7 36,9 @@ def index(page):
@templated
def view(slug):
    """Show a single news item."""
    item = news_service.find_item_by_slug(g.party.brand.id, slug)
    brand_id = g.party.brand_id

    item = news_service.find_item_by_slug(brand_id, slug)

    if item is None:
        abort(404)

M byceps/blueprints/newsletter/views.py => byceps/blueprints/newsletter/views.py +2 -2
@@ 21,7 21,7 @@ blueprint = create_blueprint('newsletter', __name__)
@respond_no_content
def subscribe():
    user = _get_current_user_or_404()
    brand_id = g.party.brand.id
    brand_id = g.party.brand_id

    newsletter_service.subscribe(user.id, brand_id)



@@ 32,7 32,7 @@ def subscribe():
@respond_no_content
def unsubscribe():
    user = _get_current_user_or_404()
    brand_id = g.party.brand.id
    brand_id = g.party.brand_id

    newsletter_service.unsubscribe(user.id, brand_id)


M byceps/blueprints/party/views.py => byceps/blueprints/party/views.py +1 -1
@@ 40,7 40,7 @@ def info():
@templated
def archive():
    """Show archived parties."""
    brand_id = g.party.brand.id
    brand_id = g.party.brand_id
    archived_parties = party_service.get_archived_parties_for_brand(brand_id)

    party_ids = {party.id for party in archived_parties}

M byceps/blueprints/terms/views.py => byceps/blueprints/terms/views.py +3 -1
@@ 25,7 25,9 @@ blueprint = create_blueprint('terms', __name__)
@templated
def view_current():
    """Show the current version of this brand's terms and conditions."""
    version = terms_service.get_current_version(g.party.brand.id)
    brand_id = g.party.brand_id

    version = terms_service.get_current_version(brand_id)

    return {
        'version': version,

M byceps/blueprints/user/views.py => byceps/blueprints/user/views.py +3 -3
@@ 95,7 95,7 @@ def view_current():
        abort(404)

    if get_site_mode().is_public():
        brand_id = g.party.brand.id
        brand_id = g.party.brand_id
        subscribed_to_newsletter = newsletter_service.is_subscribed(user.id,
                                                                    brand_id)
    else:


@@ 170,9 170,9 @@ def create():
        return create_form(form)

    try:
        brand_id = g.party.brand_id
        user = user_service.create_user(screen_name, email_address, password,
                                        first_names, last_name,
                                        g.party.brand.id,
                                        first_names, last_name, brand_id,
                                        subscribe_to_newsletter)
    except user_service.UserCreationFailed:
        flash_error('Das Benutzerkonto für "{}" konnte nicht angelegt werden.',