"""
Core app views
"""

import py.error  # pylint:disable=import-error

from flask import render_template, request
from flask_security import login_required

from dockci.models.job import all_jobs
from dockci.server import APP, CONFIG
from dockci.util import request_fill


@APP.route('/')
def index():
    """
    View to display the list of all jobs
    """
    return render_template('index.html', jobs=list(all_jobs()))


@APP.route('/config', methods=('GET', 'POST'))
@login_required
def config_edit_view():
    """
    View to edit global config
    """
    restart_fields = (
        'secret',
        'docker_use_env_vars', 'docker_hosts',
        'mail_host_string', 'mail_use_tls', 'mail_use_ssl',
        'mail_username', 'mail_password', 'mail_default_sender',
        'security_registerable', 'security_recoverable',
        'github_client_id', 'github_client_secret',
    )
    all_fields = restart_fields + (
        'docker_use_registry', 'docker_registry',
        'github_client_id', 'github_client_secret',
    )

    saved = request_fill(CONFIG, all_fields)

    try:
        CONFIG.load()

    except py.error.ENOENT:
        pass

    if saved:
        restart_needed = any((
            (
                attr in request.form and
                request.form[attr] != getattr(CONFIG, attr)
            )
            for attr in restart_fields
        ))
        if restart_needed:
            CONFIG.restart_needed = True

    return render_template('config_edit.html')

@@ -835,33 +835,27 @@
     'github_
-client_id
+key
 ', 'github_c
@@ -845,39 +845,32 @@
 b_key', 'github_
-client_
 secret',%0A    )%0A 
@@ -958,60 +958,8 @@
 y',%0A
-        'github_client_id', 'github_client_secret',%0A
     

Fix github config