350e7d4
#!/usr/bin/env python
6f5a507
# -*- coding: utf-8 -*-
350e7d4
""" Populate the hubs db with some dev data. """
350e7d4
cfa2cef
from __future__ import unicode_literals
cfa2cef
07f4d41
import hubs.app
154fad9
import hubs.database
8d55dff
import hubs.models
c178b3e
import hubs.widgets
0d65583
from hubs.utils.fedmsg import get_fedmsg_config
8d55dff
7ab1e18
7ab1e18
fedmsg_config = get_fedmsg_config()
154fad9
hubs.database.init(
154fad9
    fedmsg_config['hubs.sqlalchemy.uri'], True, True)
154fad9
db = hubs.database.Session()
8d55dff
2c317a8
placekitten = "https://placekitten.com/g/320/320"
2c317a8
c178b3e
# Register widgets we will use
c178b3e
hubs.widgets.registry.register_list([
27332a7
    "hubs.widgets.meetings:Meetings",
2c317a8
    "hubs.widgets.feed:Feed",
6f5a507
    "hubs.widgets.memberships:Memberships",
6e44e33
    "hubs.widgets.newestissues:NewestIssues",
6e44e33
c178b3e
    ])
c178b3e
6f5a507
07f4d41
def create_users():
6f5a507
    users = {'mrichard': {
6f5a507
        'fullname': 'mrichard',
6f5a507
        'description': 'This is a description for mrichard'},
6f5a507
        'duffy': {
6f5a507
        'fullname': 'Máirín Duffy',
6f5a507
        'description': 'You can call me Mo. I am a principal '
6f5a507
        'interaction designer with Red Hat Inc.'
6f5a507
        'and come from a varied background - '
6f5a507
        'Computer Science, Human Computer Interaction, and'
6f5a507
        'Visual Design'},
6f5a507
        'ryanlerch':
6f5a507
        {'fullname': 'Ryan Lerch'},
6f5a507
        'gnokii':
6f5a507
        {'fullname': 'Sirko Kemter'},
6f5a507
        'nask0':
6f5a507
        {'fullname': 'Atanas Beloborodov'},
6f5a507
        'abompard':
6f5a507
        {'fullname': 'Aurélien Bompard'},
6f5a507
        'decause':
6f5a507
        {'fullname': 'Remy DeCausemaker '},
6f5a507
        'ralph':
6f5a507
        {'fullname': 'Ralph Bean'},
6f5a507
        'lmacken':
6f5a507
        {'fullname': 'Luke Macken'},
6f5a507
        'croberts':
6f5a507
        {'fullname': 'Chris Roberts'},
6f5a507
        'mattdm':
6f5a507
        {'fullname': 'Matthew Miller'},
6f5a507
        'sayanchowdhury':
6f5a507
        {'fullname': 'Sayan Chowdhury'},
6f5a507
        'pravins':
6f5a507
        {'fullname': 'Pravin Satpute'},
6f5a507
        'keekri':
6f5a507
        {'fullname': 'Keerthana Krishnan',
6f5a507
         'description': 'Hello, I\'m Keerthana, and I\'m a student at '
6f5a507
         'the Govt. Model Engineering College, Thrikkakara, Ernakulam,'
6f5a507
         'Kerala, India. I am majoring in Computer Science and '
6f5a507
         'Engineering and intend to graduate in 2016. I have been '
6f5a507
         'using Linux (and Fedora) since I remember.'},
6f5a507
        'linuxmodder':
6f5a507
        {'fullname': 'Corey Sheldon '},
6f5a507
        'bee2502':
6f5a507
        {'fullname': 'Bhagyashree'},
6f5a507
        'jflory7':
6f5a507
        {'fullname': 'Justin W. Flory'},
6f5a507
        'robyduck':
6f5a507
        {'fullname': 'Robert Mayr'}
6f5a507
    }
6f5a507
    for username, details in users.items():
6f5a507
        fullname = details["fullname"]
07f4d41
        print("Creating account for %r" % username)
07f4d41
        hubs.models.User.get_or_create(
07f4d41
            username=username, fullname=fullname)
6f5a507
        db.commit()
6f5a507
        if 'description' in details:
6f5a507
            userhub = hubs.models.Hub.by_name(username, "user")
6f5a507
            userhub.config.update(dict(
6f5a507
                description=details["description"]
6f5a507
                ))
6f5a507
07f4d41
07f4d41
def create_teams():
6f5a507
    # Ambassadors
6f5a507
    hub = hubs.models.Hub(name='ambassadors', hub_type="team")
07f4d41
    db.add(hub)
07f4d41
    hub.config.update(dict(
6f5a507
        summary='Fedora Ambassadors',
07f4d41
        avatar=placekitten,
2720130
        description=(
6f5a507
            'Ambassadors are the representatives of Fedora. Ambassadors '
6f5a507
            'ensure the public understand Fedora\'s principles and the '
6f5a507
            'work that Fedora is doing. Additionally Ambassadors are '
6f5a507
            'responsible for helping to grow the contributor base, and '
6f5a507
            'to act as a liaison between other FLOSS projects and the '
6f5a507
            'Fedora community.'),
6f5a507
        rules_url='https://fedoraproject.org/wiki/Ambassadors',
6f5a507
        calendar='ambassadors',
6f5a507
        chat_domain="irc.freenode.net",
6f5a507
        chat_channel="#fedora-ambassadors",
6f5a507
        mailing_list="ambassadors@lists.fedoraproject.org"
2720130
        ))
6f5a507
    widget = hubs.models.Widget(plugin='memberships', index=1)
07f4d41
    hub.widgets.append(widget)
50b9c71
6f5a507
    widget = hubs.models.Widget(plugin='meetings', index=2)
07f4d41
    hub.widgets.append(widget)
07f4d41
2720130
    widget = hubs.models.Widget(plugin='feed', index=1, left=True)
07f4d41
    hub.widgets.append(widget)
50b9c71
07f4d41
    db.commit()
50b9c71
48dfdf4
# ############# CommOps
07f4d41
    hub = hubs.models.Hub(name='commops', hub_type="team")
07f4d41
    db.add(hub)
07f4d41
    hub.config["summary"] = 'The Fedora Community Operations Team'
07f4d41
    hub.config["chat_domain"] = 'irc.freenode.net'
6f5a507
    hub.config["chat_channel"] = '#fedora-commops'
1ce20ab
    hub.config["pagure"] = ['fedora-commops']
07f4d41
    hub.config["calendar"] = 'commops'
2720130
    hub.config["description"] = (
2720130
        "Bringing more heat and light to Fedora, so you don't "
2720130
        "have to choose between 'building things' and 'building communities "
2720130
        "that build things'."
2720130
    )
6f5a507
    hub.config["mailing_list"] = 'commops@lists.fedoraproject.org'
e58fb8e
    hub.config["rules_url"] = 'https://fedoraproject.org/wiki/CommOps'
07f4d41
6f5a507
    widget = hubs.models.Widget(plugin='memberships', index=1)
07f4d41
    hub.widgets.append(widget)
34e26b6
6f5a507
    widget = hubs.models.Widget(plugin='meetings', index=2)
07f4d41
    hub.widgets.append(widget)
07f4d41
2720130
    widget = hubs.models.Widget(plugin='feed', index=1, left=True)
07f4d41
    hub.widgets.append(widget)
34e26b6
07f4d41
    db.commit()
34e26b6
48dfdf4
# ############# Marketing team
07f4d41
    hub = hubs.models.Hub(name='marketing', hub_type="team")
07f4d41
    db.add(hub)
07f4d41
    hub.config["summary"] = 'The Fedora Marketing Team'
8a1282e
    hub.config["description"] = (
8a1282e
        'The Fedora Marketing Team develops and executes marketing strategies'
8a1282e
        ' to promote the usage and support of Fedora worldwide. Through the'
8a1282e
        ' development of processes and content, this project aims to support'
8a1282e
        ' the efforts of other Fedora projects to spread Fedora and to'
8a1282e
        ' provide a central repository of ideas and information that can be'
8a1282e
        ' used to deliver Fedora to new audiences. We work closely with the'
8a1282e
        ' Fedora Ambassadors who spread the word about Fedora at events'
8a1282e
        ' and allow the Fedora Project to interact directly with its'
8a1282e
        ' existing and prospective users.')
6f5a507
e58fb8e
    hub.config["rules_url"] = 'https://fedoraproject.org/wiki/Marketing'
6f5a507
    hub.config["mailing_list"] = 'marketing@lists.fedoraproject.org'
6f5a507
    hub.config["chat_domain"] = 'irc.freenode.net'
6f5a507
    hub.config["chat_channel"] = '#fedora-mktg'
1ce20ab
    hub.config["pagure"] = ['fedora-marketing']
6f5a507
    hub.config["calendar"] = 'marketing'
07f4d41
6f5a507
    widget = hubs.models.Widget(plugin='memberships', index=1)
07f4d41
    hub.widgets.append(widget)
53b861b
6f5a507
    widget = hubs.models.Widget(plugin='meetings', index=2)
07f4d41
    hub.widgets.append(widget)
07f4d41
2720130
    widget = hubs.models.Widget(plugin='feed', index=1, left=True)
07f4d41
    hub.widgets.append(widget)
53b861b
07f4d41
    db.commit()
53b861b
48dfdf4
# ############# Design team
6f5a507
    hub = hubs.models.Hub(name='designteam', hub_type="team")
07f4d41
    db.add(hub)
07f4d41
    hub.config["summary"] = 'The Fedora Design Team'
8a1282e
    hub.config["description"] = (
8a1282e
        'The Design Team is the design group of the Fedora project. Our'
8a1282e
        ' interests are not only in creating graphics for use by the'
8a1282e
        ' Fedora community, but also advocating the use of the'
8a1282e
        ' creative tools that are a part of Fedora.')
6f5a507
e58fb8e
    hub.config["rules_url"] = 'https://fedoraproject.org/wiki/Design'
6f5a507
    hub.config["meetings_text"] = 'Meetings are every 2nd Tuesday at 16:00 UTC'
6f5a507
    hub.config["mailing_list"] = 'design-team@lists.fedoraproject.org'
6f5a507
    hub.config["chat_domain"] = 'irc.freenode.net'
6f5a507
    hub.config["chat_channel"] = '#fedora-design'
6e44e33
    hub.config["pagure"] = ['design', "fedora-badges"]
6e44e33
    hub.config["github"] = ['fedora-infra/bodhi']
6f5a507
    hub.config["calendar"] = 'design'
07f4d41
6f5a507
    widget = hubs.models.Widget(plugin='memberships', index=1)
07f4d41
    hub.widgets.append(widget)
9dba27c
6f5a507
    widget = hubs.models.Widget(plugin='meetings', index=2)
07f4d41
    hub.widgets.append(widget)
07f4d41
6e44e33
    widget = hubs.models.Widget(plugin='newestissues', index=3)
6e44e33
    hub.widgets.append(widget)
6e44e33
2720130
    widget = hubs.models.Widget(plugin='feed', index=1, left=True)
07f4d41
    hub.widgets.append(widget)
8d55dff
07f4d41
    db.commit()
53b861b
0d0c309
6f5a507
# ############# Infra team -- commented out, as there is no infra FAS group yet
6f5a507
    # hub = hubs.models.Hub(name='infrastructure', hub_type="team")
6f5a507
    # db.add(hub)
6f5a507
    # hub.config["summary"] = 'The Fedora Infra Team'
6f5a507
    # hub.config["description"] = """
6f5a507
    # The Infrastructure Team consists of dedicated volunteers and professional
6f5a507
    # managing the servers, building the tools and utilities, and creating new
6f5a507
    # applications to make Fedora development a smoother process. We're located
6f5a507
    # all over the globe and communicate primarily by IRC and e-mail.
6f5a507
    # """
6f5a507
    # hub.config["rules_url"] = 'https://fedoraproject.org/wiki/Infrastructure'
6f5a507
    # hub.config["meetings_text"] = 'Weekly in #fedora-meeting at 1800 UTC'
6f5a507
6f5a507
    # widget = hubs.models.Widget(
6f5a507
    #     plugin='meetings', index=1, _config=json.dumps({
6f5a507
    #         'n_meetings': 4
6f5a507
    #     }))
6f5a507
    # hub.widgets.append(widget)
6f5a507
6f5a507
    # widget = hubs.models.Widget(plugin='feed', index=1, left=True)
6f5a507
    # hub.widgets.append(widget)
6f5a507
6f5a507
    # db.commit()
07f4d41
07f4d41
07f4d41
def main():
3641a76
    base_url = "https://{}".format(hubs.app.app.config["DEFAULT_SERVER_NAME"])
07f4d41
    with hubs.app.app.app_context():
3641a76
        with hubs.app.app.test_request_context(base_url=base_url):
3641a76
            create_users()
3641a76
            create_teams()
07f4d41
07f4d41
07f4d41
if __name__ == "__main__":
07f4d41
    main()