Exemple #1
0
def index():
    if "g" in flask.session:
        user = github.current_user()
        flask.session["e"] = user["email"]
        orgs = github.orgs()
        org_repos = [github.repos(org=org["login"]) for org in orgs]
        return flask.render_template("index_logged_in.html",
                                     user=user,
                                     repos=github.repos(),
                                     orgs=orgs, org_repos=org_repos)
    return flask.render_template("index.html", auth_url=github.auth_url())
Exemple #2
0
def repo_page(name, org=None):
    user = github.current_user()
    repo = repo_data(name, org and org["login"])

    if not repo:
        return flask.abort(404, "No matching repo")

    existing_own = list(db.existing_own(name, user["login"]))
    existing_not_own = list(db.existing_not_own(name, user["login"]))

    return flask.render_template("repo.html", repo=repo, org=org,
                                 existing_own=existing_own,
                                 existing_not_own=existing_not_own,
                                 **gen_xsrf(["create"]))
Exemple #3
0
def repo_create(name, org=None):
    user = github.current_user()
    repo = repo_data(name, org and org["login"])

    if not repo:
        return flask.abort(404, "No matching repo")

    username = org and org["login"] or user["login"]

    to_invite = set()
    to_invite.update(github.collaborators(username, name))
    to_invite.update(github.contributors(username, name))
    if org:
        to_invite.update(github.members(org["login"]))
    to_invite.update(github.forkers(username, name))
    to_invite.update(github.watchers(username, name))
    to_invite -= set([user["login"], "invalid-email-address"])

    description = repo["description"]
    group = fiesta_api.create_group(default_name=repo["name"],
                                    description=description)

    # Gitlists are public, archived and have the repo name as a subject-prefix
    group.add_application("public", group_name=repo["name"])
    group.add_application("subject_prefix", prefix=repo["name"])
    group.add_application("archive")

    github_url = "https://github.com/%s/%s" % (username, repo["name"])
    welcome_message = {"subject": "Welcome to %[email protected]" % repo["name"],
                       "markdown": """
Your [Gitlist](https://gitlists.com) for [%s](%s) has been created.

The [list page](https://fiesta.cc/list/%s) is the archive *and* where new members will need to go to join the list, so you might want to add it to your repo's README.

If you have any questions, send us an email at [email protected].

Have a great day!
""" % (repo["name"], github_url, group.id)}
    group.add_member(user["email"],
                     display_name=user.get("name", ""),
                     welcome_message=welcome_message)

    for username in to_invite:
        db.pending_invite(repo["name"], github_url, user["login"],
                          username, group.id)

    db.new_list(repo["name"], user["login"], group.id)
    flask.flash("Your Gitlist has been created - check your email at '%s'." % user["email"])
    return flask.redirect("/")
Exemple #4
0
import github as gh
from snug.utils import replace

CRED_PATH = Path('~/.snug/github.json').expanduser()
auth = tuple(json.loads(CRED_PATH.read_bytes()))

resolve = partial(gh.resolve, auth=auth)

all_orgs = gh.orgs()
one_org = gh.org('github')
one_repo = gh.repo(owner='github', name='hub')
all_repos = gh.repos()

assigned_issues = gh.issues()

current_user = gh.current_user()
my_issues = current_user.issues()

repo_issues = one_repo.issues()
one_repo_issue = one_repo.issue(123)
one_repos_fixed_bugs = replace(repo_issues, labels='bug', state='closed')

live = pytest.config.getoption('--live')


def test_all_orgs():
    assert isinstance(all_orgs, snug.Query)
    assert all_orgs.__rtype__ == t.List[gh.Organization]
    assert all_orgs.__req__ == snug.Request('organizations')

    if live: