Merge pull request #1 from amakhnach/master

init
This commit is contained in:
Oleg Pidsadnyi 2013-06-07 14:18:16 -07:00
commit b32202dd5b
28 changed files with 9762 additions and 114 deletions

3
.gitignore vendored
View File

@ -40,6 +40,9 @@ nosetests.xml
# Sublime
/*.sublime-*
# Pycharm
.idea
# virtualenv
/.Python
/lib

View File

@ -1,19 +0,0 @@
#!/usr/bin/env python
from opster import command, dispatch
from .admin import admin
from .shop import shop
@command()
def runadmin(host=('a', '127.0.0.1', 'bind address')):
admin.run(debug=True, host=host)
@command()
def runshop(host=('a', '127.0.0.1', 'bind address')):
shop.run(debug=True, host=host)
if __name__ == '__main__':
dispatch()

View File

@ -0,0 +1,29 @@
from flask import Flask, Blueprint
from flask.ext.admin import Admin
from flask.ext.login import LoginManager
from flask.ext.sqlalchemy import SQLAlchemy
login_manager = LoginManager()
app = Flask(__name__)
app.config.from_object('settings')
app.secret_key = 'A0Zr98j/3yX R~XHH!jmN]LWX/,?RT'
db = SQLAlchemy(app)
from flask.ext.admin.contrib.sqlamodel import ModelView
from pytest_bdd_example import dashboard
from pytest_bdd_example.dashboard.models import User
# app.register_blueprint(dashboard.bp, url_prefix='/dashboard')
# login_manager.init_app(app)
# @login_manager.user_loader
# def load_user(userid):
# return User.get(userid)
admin_panel = Admin(app)
admin_panel.add_view(ModelView(User, db.session, endpoint='users'))

View File

@ -1,13 +0,0 @@
from flask import Flask
from .settings import TEMPLATES_ROOT, MEDIA_ROOT
from ..auth import bp as bp_auth
app = Flask(
__name__,
template_folder=TEMPLATES_ROOT,
static_folder=MEDIA_ROOT,
)
app.register_blueprint(bp_auth, url_prefix='/auth')

View File

@ -1,7 +0,0 @@
from flask import render_template
from __package__ import app
@app.route('/')
def dashboard():
return render_template('dashboard.html')

View File

@ -1,9 +0,0 @@
import os
DEBUG = True
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(BASE_PATH, 'media')
TEMPLATES_ROOT = os.path.join(BASE_PATH, 'templates', 'admin')
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/pytestbdd-example.db'

View File

@ -1,3 +0,0 @@
from flask import Blueprint
bp = Blueprint(__name__)

View File

@ -1,14 +0,0 @@
from flaskext.sqlalchemy import SQLAlchemy
from flaskext.auth.models.sa import get_user_class
from __package__ import bp
db = SQLAlchemy(bp)
UserBase = get_user_class(db.Model)
class User(UserBase):
# Extend the user model
pass

View File

@ -0,0 +1,3 @@
from flask import Blueprint
bp = Blueprint('dashboard', __name__)

View File

@ -0,0 +1,27 @@
from pytest_bdd_example import db
ROLE_USER = 0
ROLE_ADMIN = 1
class User(db.Model):
uuid = db.Column(db.Integer, primary_key=True)
username = db.Column(db.String(64), unique=True)
email = db.Column(db.String(120), unique=True)
password = db.Column(db.String(20))
role = db.Column(db.SmallInteger, default=ROLE_USER)
def is_authenticated(self):
return True
def is_active(self):
return True
def is_anonymous(self):
return False
def get_id(self):
return unicode(self.id)
def __repr__(self):
return '<User %r>' % (self.username)

View File

@ -0,0 +1,12 @@
from flask import render_template
from flask.ext.login import current_user
from pytest_bdd_example.dashboard import bp
# @bp.route('/')
# def index(template='dashboatd.html'):
#
# if not current_user.is_authenticated():
# template = "login.html"
#
# return render_template(template)

11
pytest_bdd_example/manage.py Executable file
View File

@ -0,0 +1,11 @@
#!/usr/bin/env python
from flask.ext.script import Manager, Shell, Server
from pytest_bdd_example import app
manager = Manager(app)
manager.add_command("runserver", Server("127.0.0.1"))
manager.add_command("shell", Shell(use_ipython=True))
manager.run()

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*!
* Bootstrap Responsive v2.3.1
* Bootstrap Responsive v2.3.2
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

Before

Width:  |  Height:  |  Size: 8.6 KiB

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
import os
DEBUG = True
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(BASE_PATH, '../media')
TEMPLATES_ROOT = os.path.join(BASE_PATH, '../templates', 'admin')
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_PATH, '../pytest-bdd-example.db')

View File

@ -1,38 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Shop - {% block title %}Dashboard{% endblock %}</title>
<link href="/media/css/bootstrap.min.css" rel="stylesheet">
<link href="/media/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="/media/css/dashboard.css" rel="stylesheet">
<script type="text/javascript" src="/media/js/jquery-1.7.1.min.js"></script>
<script src="/media/js/bootstrap.min.js"></script>
{% block extra_head %}{% endblock %}
</head>
<body>
<div id="form" class="modal hide" role="dialog" tabindex="-1" aria-labelledby="modal-title"></div>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="/">Dashboard</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href="/">Home</a></li>
</ul>
</div>
</div>
</div>
</div>
<ul class="breadcrumb">
<li><a href="/">Home</a> <span class="divider">/</span></li>
{% block breadcrumbs %}{% endblock %}
</ul>
<div class="container">
{% block content %}{% endblock %}
</div>
</body>
</html>

View File

@ -1 +0,0 @@
{% extends "base.html" %}

View File

@ -0,0 +1,67 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Shop - {% block title %}Dashboard{% endblock %}</title>
<link href="{{ url_for("static", filename="bootstrap/css/bootstrap.css") }}" rel="stylesheet">
{# <link href="/media/bootstrap/css/dashboard.css" rel="stylesheet">#}
<script type="text/javascript" src="{{ url_for("static", filename="libs/jquery-1.10.1.min.js") }}"></script>
<script src="{{ url_for("static", filename="bootstrap/js/bootstrap.min.js") }}"></script>
{% block extra_head %}{% endblock %}
<style type="text/css">
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #f5f5f5;
}
.form-signin {
max-width: 300px;
padding: 19px 29px 29px;
margin: 0 auto 20px;
background-color: #fff;
border: 1px solid #e5e5e5;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin input[type="text"],
.form-signin input[type="password"] {
font-size: 16px;
height: auto;
margin-bottom: 15px;
padding: 7px 9px;
}
</style>
</head>
<body>
{% block menu %}
<div id="form" class="modal hide" role="dialog" tabindex="-1" aria-labelledby="modal-title"></div>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="brand" href="/">Dashboard</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li class="active"><a href=".">Home</a></li>
</ul>
</div>
</div>
</div>
</div>
{% endblock %}
<div class="container">
{% block content %}{% endblock %}
</div>
</body>
</html>

View File

@ -0,0 +1,7 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
{% endblock %}

View File

@ -0,0 +1,17 @@
{% extends "base.html" %}
{% block menu %}
{% endblock %}
{% block content %}
<form class="form-signin">
<h2 class="form-signin-heading">Please sign in</h2>
<input type="text" class="input-block-level" placeholder="Email address">
<input type="password" class="input-block-level" placeholder="Password">
<label class="checkbox">
<input type="checkbox" value="remember-me"> Remember me
</label>
<button class="btn btn-large btn-primary" type="submit">Sign in</button>
</form>
{% endblock %}