Blob Blame Raw
#!/usr/bin/env python
""" Populate the hubs db with some dev data. """
from __future__ import unicode_literals
import json
import hubs.models
import hubs.widgets
from hubs.utils import get_fedmsg_config
fedmsg_config = get_fedmsg_config()
session = hubs.models.init(fedmsg_config['hubs.sqlalchemy.uri'], True, True)
# Register widgets we will use
hubs.widgets.registry.register_list([
    "hubs.widgets.contact:Contact",
    "hubs.widgets.rules:Rules",
    "hubs.widgets.meetings:Meetings",
    "hubs.widgets.about:About",
    "hubs.widgets.sticky:Sticky",
    "hubs.widgets.dummy:Dummy",
    ])
users = ['mrichard', 'duffy', 'ryanlerch', 'gnokii', 'nask0',
         'abompard', 'decause', 'ralph', 'lmacken', 'croberts', 'mattdm',
         'pravins', 'keekri', 'linuxmodder', 'bee2502', 'jflory7']
for username in users:
    fullname = 'Full Name Goes Here'
    print("Creating account for %r" % username)
    hubs.models.User.get_or_create(
        session, username=username, fullname=fullname)
session.commit()
# ############# Internationalizationteam
hub = hubs.models.Hub(name='i18n', archived=True)
session.add(hub)
session.add(hubs.models.HubConfig(
    hub=hub, summary='The Internationalization Team'))
widget = hubs.models.Widget(plugin='contact', index=0)
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='rules', index=1, _config=json.dumps({
        'link': 'https://fedoraproject.org/wiki/I18N',
        'schedule_text': None,
        'schedule_link': None,
        'minutes_link': 'https://meetbot.fedoraproject.org/sresults/'
                        '?group_id=i18n&type=team',
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='meetings', index=2,
                            _config=json.dumps({'calendar': 'i18n'}))
hub.widgets.append(widget)
# Added a hubs about widget
widget = hubs.models.Widget(
    plugin='about', index=3, _config=json.dumps({
        "text": "I'm a Fedora user, and this is my about widget text!",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='sticky', index=1, left=True, _config=json.dumps({
        'text': """
<p>The Fedora I18N project works on internationalization (i18n) to support the
localization (l10n) of Fedora in many languages. Translation of Fedora software
and documentation are handled by the Fedora L10N project.</p> <p>The goals of
the Project are to:</p> <ul><li>Develop, package, and maintain applications
like input methods for different languages</li> <li>Improve applications and
utilities to support and process different languages</li> <li>Quality-assure
that existing applications meet i18n standards</li> <li>Support the
infrastructure of the Fedora Localization Project</li></ul>
""",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
hub.widgets.append(widget)
# Set up some memberships
hub.subscribe(hubs.models.User.by_username('pravins'), 'owner')
hub.subscribe(hubs.models.User.by_username('decause'), 'member')
hub.subscribe(hubs.models.User.by_username('ralph'), 'subscriber')
session.commit()
# ############# CommOps
hub = hubs.models.Hub(name='commops')
session.add(hub)
session.add(hubs.models.HubConfig(
    hub=hub, summary='The Fedora Community Operations Team'))
widget = hubs.models.Widget(plugin='contact', index=0)
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='rules', index=1, _config=json.dumps({
        'link': 'https://fedoraproject.org/wiki/CommOps',
        'schedule_text': None,
        'schedule_link': None,
        'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
                        '?group_id=commops&type=team',
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='meetings', index=2, _config=json.dumps({
        'calendar': 'commops', 'n_meetings': 4
    }))
hub.widgets.append(widget)
# Added a hubs about widget
widget = hubs.models.Widget(plugin='about', index=3,
                            _config=json.dumps({
                                "text": "Community + Operations = CommOps",
                            }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='sticky', index=1, left=True, _config=json.dumps({
        'text': "Bringing more heat and light to Fedora, so you don't have "
                "to choose between 'building things' and 'building "
                "communities that build things.'",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
hub.widgets.append(widget)
# Set up some memberships
hub.subscribe(hubs.models.User.by_username('decause'), 'owner')
hub.subscribe(hubs.models.User.by_username('jflory7'), 'member')
hub.subscribe(hubs.models.User.by_username('bee2502'), 'member')
hub.subscribe(hubs.models.User.by_username('keekri'), 'member')
hub.subscribe(hubs.models.User.by_username('linuxmodder'), 'member')
session.commit()
# ############# Marketing team
hub = hubs.models.Hub(name='marketing')
session.add(hub)
session.add(hubs.models.HubConfig(
    hub=hub, summary='The Fedora Marketing Team'))
widget = hubs.models.Widget(plugin='contact', index=0)
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='rules', index=1, _config=json.dumps({
        'link': 'https://fedoraproject.org/wiki/Marketing',
        'schedule_text': None,
        'schedule_link': None,
        'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
                        '?group_id=fedora-mktg&type=channel',
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='meetings', index=2, _config=json.dumps({
        'calendar': 'marketing', 'n_meetings': 4
    }))
hub.widgets.append(widget)
# Added a hubs about widget
widget = hubs.models.Widget(
    plugin='about', index=3, _config=json.dumps({
        "text": "I'm a Fedora user, and this is my about widget text!",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='sticky', index=1, left=True, _config=json.dumps({
        'text': """
The Fedora Marketing Team develops and executes marketing strategies to promote
the usage and support of Fedora worldwide. Through the development of processes
and content, this project aims to support the efforts of other Fedora projects
to spread Fedora and to provide a central repository of ideas and information
that can be used to deliver Fedora to new audiences. We work closely with the
Fedora Ambassadors who spread the word about Fedora at events and allow the
Fedora Project to interact directly with its existing and prospective users.
""",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
hub.widgets.append(widget)
# Set up some memberships
hub.subscribe(hubs.models.User.by_username('croberts'), 'owner')
hub.subscribe(hubs.models.User.by_username('ryanlerch'), 'owner')
hub.subscribe(hubs.models.User.by_username('mrichard'), 'member')
hub.subscribe(hubs.models.User.by_username('mattdm'), 'member')
hub.subscribe(hubs.models.User.by_username('decause'), 'member')
hub.subscribe(hubs.models.User.by_username('ralph'), 'subscriber')
session.commit()
# ############# Design team
hub = hubs.models.Hub(name='designteam')
session.add(hub)
session.add(hubs.models.HubConfig(
    hub=hub, summary='The Fedora Design Team'))
widget = hubs.models.Widget(plugin='contact', index=0)
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='rules', index=1, _config=json.dumps({
        'link': 'https://fedoraproject.org/wiki/Design',
        'schedule_text': 'Meetings are every other Tuesday at 16:00 UTC',
        'schedule_link': 'https://apps.fedoraproject.org/calendar/design/',
        'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
                        '?group_id=fedora-design&type=channel',
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='meetings', index=2, _config=json.dumps({
        'calendar': 'design', 'n_meetings': 4
    }))
hub.widgets.append(widget)
# Added a hubs about widget
widget = hubs.models.Widget(
    plugin='about', index=3, _config=json.dumps({
        "text": "I'm a Fedora user, and this is my about widget text!",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='sticky', index=1, left=True, _config=json.dumps({
        'text': """
The Design Team is the design group of the Fedora project. Our interests are
not only in creating graphics for use by the Fedora community, but also in
advocating the use of the creative tools that are a part of Fedora.
""",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='dummy', index=2, left=True)
hub.widgets.append(widget)
# Set up some memberships
hub.subscribe(hubs.models.User.by_username('duffy'), 'owner')
hub.subscribe(hubs.models.User.by_username('ryanlerch'), 'owner')
hub.subscribe(hubs.models.User.by_username('gnokii'), 'owner')
hub.subscribe(hubs.models.User.by_username('mrichard'), 'owner')
hub.subscribe(hubs.models.User.by_username('nask0'), 'member')
hub.subscribe(hubs.models.User.by_username('decause'), 'member')
hub.subscribe(hubs.models.User.by_username('ralph'), 'subscriber')
session.commit()
# ############# Infra team
hub = hubs.models.Hub(name='infrastructure')
session.add(hub)
session.add(hubs.models.HubConfig(
    hub=hub, summary='The Fedora Infra Team'))
widget = hubs.models.Widget(plugin='contact', index=0)
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='rules', index=1, _config=json.dumps({
        'link': 'https://fedoraproject.org/wiki/Infrastructure',
        'schedule_text': 'We meet weekly in #fedora-meeting at 18:00 UTC',
        'schedule_link':
            'https://apps.fedoraproject.org/calendar/infrastructure/',
        'minutes_link': 'http://meetbot.fedoraproject.org/sresults/'
                        '?group_id=infrastructure&type=team',
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='meetings', index=2, _config=json.dumps({
        'calendar': 'infrastructure', 'n_meetings': 4
    }))
hub.widgets.append(widget)
# Added a hubs about widget
widget = hubs.models.Widget(
    plugin='about', index=3, _config=json.dumps({
        "text": "I'm a Fedora user, and this is my about widget text!",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(
    plugin='sticky', index=2, left=True, _config=json.dumps({
        'text': """
The Infrastructure Team consists of dedicated volunteers and professionals
managing the servers, building the tools and utilities, and creating new
applications to make Fedora development a smoother process. We're located all
over the globe and communicate primarily by IRC and e-mail.
""",
    }))
hub.widgets.append(widget)
widget = hubs.models.Widget(plugin='dummy', index=3, left=True)
hub.widgets.append(widget)
vc = hubs.models.VisitCounter().get_or_create(session, 'ralph', 'mrichard')
hubs.models.VisitCounter().increment_visits(session, 'ralph', 'mrichard')
hub.subscribe(hubs.models.User.by_username('ralph'), 'owner')
hub.subscribe(hubs.models.User.by_username('abompard'), 'owner')
hub.subscribe(hubs.models.User.by_username('lmacken'), 'owner')
hub.subscribe(hubs.models.User.by_username('nask0'), 'member')
hub.subscribe(hubs.models.User.by_username('decause'), 'subscriber')
session.commit()