# Path: bibserver/core.py
# def create_app():
# def configure_app(app):
# def setup_error_email(app):
#     ADMINS = app.config.get('ADMINS', '')
# 
# Path: bibserver/view/account.py
# def index():
# def login():
# def logout():
# def existscheck(form, field):
# def register():
# class LoginForm(Form):
# class RegisterForm(Form):


import os
import urllib2
import unicodedata
import httplib
import json
import subprocess
import bibserver.dao
import bibserver.util as util
import bibserver.importer
import bibserver.ingest
    import bibserver.search
from copy import deepcopy
from datetime import datetime
from flask import Flask, jsonify, json, request, redirect, abort, make_response
from flask import render_template, flash
from flask.views import View, MethodView
from flask_login import login_user, current_user
from bibserver.config import config
from bibserver.core import app, login_manager
from bibserver.view.account import blueprint as account
from bibserver import auth
        if not auth.collection.create(current_user, None):
            flash('You need to login to create a collection.')
            return redirect('/account/login')
        if request.values.get("source") is not None:
            return self.post()        
        return render_template('create.html')

    def post(self):
        if not auth.collection.create(current_user, None):
            abort(401)

        # create the new collection for current user
        coll = {
            'label' : request.values.get('collection'),
            'license' : request.values.get('license')
        }
        i = bibserver.importer.Importer(current_user)
        collection, records = i.index(coll, {})
        return redirect(collection['owner'] + '/' + collection['collection'])

# a class for use when upload / create are disabled
class NoUploadOrCreate(MethodView):
    def get(self):
        return render_template('disabled.html')

    def post(self):
        abort(401)    

# set the upload / create views as appropriate
if config["allow_upload"]:

# Path: bibserver/core.py
# def create_app():
# def configure_app(app):
# def setup_error_email(app):
#     ADMINS = app.config.get('ADMINS', '')
# 
# Path: bibserver/view/account.py
# def index():
# def login():
# def logout():
# def existscheck(form, field):
# def register():
# class LoginForm(Form):
# class RegisterForm(Form):


# Path: bibserver/web.py
import os
import urllib2
import unicodedata
import httplib
import json
import subprocess
import bibserver.dao
import bibserver.util as util
import bibserver.importer
import bibserver.ingest
    import bibserver.search
from copy import deepcopy
from datetime import datetime
from flask import Flask, jsonify, json, request, redirect, abort, make_response
from flask import render_template, flash
from flask.views import View, MethodView
from flask_login import login_user, current_user
from bibserver.config import config
from bibserver.core import app, login_manager
from bibserver.view.account import blueprint as account
from bibserver import auth

        if not auth.collection.create(current_user, None):
            flash('You need to login to create a collection.')
            return redirect('/account/login')
        if request.values.get("source") is not None:
            return self.post()        
        return render_template('create.html')

    def post(self):
        if not auth.collection.create(current_user, None):
            abort(401)

        # create the new collection for current user
        coll = {
            'label' : request.values.get('collection'),
            'license' : request.values.get('license')
        }
        i = bibserver.importer.Importer(current_user)
        collection, records = i.index(coll, {})
        return redirect(collection['owner'] + '/' + collection['collection'])

# a class for use when upload / create are disabled
class NoUploadOrCreate(MethodView):
    def get(self):
        return render_template('disabled.html')

    def post(self):
        abort(401)    

# set the upload / create views as appropriate
if config["allow_upload"]:

    app.add_url_rule('/upload', view_func=UploadView.as_view('upload'))