# -*- coding: utf-8 -*-

import os

from flask import Blueprint, request, jsonify
from flask.ext.mako import render_template
from werkzeug import secure_filename

from summer.model.entry import Entry

bp = Blueprint('admin', __name__)


@bp.route('/upload', methods=['POST', ])
def upload():
	if request.method == 'POST':
		_file = request.files['file']

		if _file:
			filename = secure_filename(_file.filename)
			_file.save(os.path.join('./fe/static/img', filename))
			return jsonify(r=True, path='/static/img/' + filename)

		return jsonify(r=False)

	return jsonify(r=False)


@bp.route('/new', methods=['GET',])
def new_draft():
	return render_template('new.html', **locals())


@@ -289,39 +289,8 @@
 ():%0A
-%09if request.method == 'POST':%0A%09
 %09_fi
@@ -317,17 +317,16 @@
 file'%5D%0A%0A
-%09
 %09if _fil
@@ -328,17 +328,16 @@
  _file:%0A
-%09
 %09%09filena
@@ -375,17 +375,16 @@
 name)%0A%09%09
-%09
 _file.sa
@@ -429,17 +429,16 @@
 ename))%0A
-%09
 %09%09return
@@ -487,17 +487,16 @@
 ename)%0A%0A
-%09
 %09return 
@@ -517,69 +517,26 @@
 e)%0A%0A
-%09return jsonify(r=False)%0A%0A%0A@bp.route('/new', methods=%5B'GET',%5D
+%0A%0A@bp.route('/new'
 )%0Ade

clear logic