Blob Blame Raw
from __future__ import unicode_literals
import json
import hubs.models
def add_user_widgets(session, hub, username, fullname):
    """ Some defaults for an individual user's hub. """
    # The feed widget works, but it needs to be cleaned up lots before we
    # throw it in by default.
    widget = hubs.models.Widget(
        plugin='feed', index=0, left=True,
        _config=json.dumps({
            'username': username,
            'message_limit': 20
        }))
    hub.widgets.append(widget)
    # Right Side Widgets
    widget = hubs.models.Widget(
        plugin='contact', index=-2,
        _config=json.dumps({
            'username': username,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='meetings', index=-1,
        _config=json.dumps({
            'calendar': 'Fedora release',
            'n_meetings': 4,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='workflow.updates2stable', index=1,
        _config=json.dumps({
            'username': username,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='my_hubs', index=3,
        _config=json.dumps({
            'username': username,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='badges', index=4,
        _config=json.dumps({
            'username': username,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='pagure_pr', index=5,
        _config=json.dumps({
            'repo': 'pagure',
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='github_pr', index=7,
        _config=json.dumps({
            'organization': 'fedora-infra',
            'display_number': 15,
        }))
    hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='bugzilla', index=8,
        _config=json.dumps({
            'username': username,
        }))
    hub.widgets.append(widget)
    hub.widgets.append(
        hubs.models.Widget(
            plugin='halp', index=9,
            _config=json.dumps({
            }))
        )
    return hub
def add_group_widgets(session, hub, name, summary,
                      # These are all things that come from FAS
                      apply_rules=None,
                      irc_channel=None,
                      irc_network=None,
                      join_message=None,
                      mailing_list=None,
                      mailing_list_url=None):
    """ Some defaults for an automatically created group hub. """
    if apply_rules:
        widget = hubs.models.Widget(
            plugin='sticky', index=0, left=True,
            _config=json.dumps({
                "text": apply_rules,
            }))
        hub.widgets.append(widget)
    if join_message:
        widget = hubs.models.Widget(
            plugin='about', index=0,
            _config=json.dumps({
                "text": join_message,
            }))
        hub.widgets.append(widget)
    widget = hubs.models.Widget(
        plugin='rules', index=1,
        _config=json.dumps({
            # TODO -- can we guess their urls?
            'link': None,
            'schedule_text': None,
            'schedule_link': None,
            'minutes_link': None,
        })
    )
    hub.widgets.append(widget)
    # IRC
    if irc_channel and irc_network:
        hub.config.chat_domain = irc_network
        hub.config.chat_channel = irc_channel
    hub.widgets.append(
        hubs.models.Widget(
            plugin='irc', index=2,
            _config=json.dumps({
                'height': 450,
            })
        )
    )
    # TODO - set up mailing list with the right mailing list.
    # TODO - set up feed with aggregate of users stuff unless we have some
    # other preset.
    return hub