Giter Site home page Giter Site logo

dpgaspar / flask-appbuilder Goto Github PK

View Code? Open in Web Editor NEW
4.5K 156.0 1.3K 44.25 MB

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more. Demo (login with guest/welcome) - http://flaskappbuilder.pythonanywhere.com/

License: BSD 3-Clause "New" or "Revised" License

Shell 0.25% Python 90.17% HTML 7.47% CSS 0.94% JavaScript 1.17%
web flask crud sql python rest-api rest authentication rbac

flask-appbuilder's Introduction

Flask App Builder

image

PyPI

image

image

image

Simple and rapid application development framework, built on top of Flask. includes detailed security, auto CRUD generation for your models, google charts and much more.

Extensive configuration of all functionality, easily integrate with normal Flask/Jinja2 development.

Checkout installation video on YouTube

Quick how to Demo from the docs (login has guest/welcome).

Change Log

Versions for further detail on what changed.

Fixes, Bugs and contributions

You're welcome to report bugs, propose new features, or even better contribute to this project.

Issues, bugs and new features

Contribute

Includes:

  • Database
    • SQLAlchemy, multiple database support: sqlite, MySQL, ORACLE, MSSQL, DB2 etc.
    • Partial support for MongoDB using MongoEngine.
    • Multiple database connections support (Vertical partitioning).
    • Easy mixin audit to models (created/changed by user, and timestamps).
  • Security
    • Automatic permissions lookup, based on exposed methods. It will grant all permissions to the Admin Role.
    • Inserts on the Database all the detailed permissions possible on your application.
    • Public (no authentication needed) and Private permissions.
    • Role based permissions.
    • Authentication support for OAuth, OpenID, Database, LDAP and REMOTE_USER environ var.
    • Support for self user registration.
  • Views and Widgets
    • Automatic menu generation.
    • Automatic CRUD generation.
    • Multiple actions on db records.
    • Big variety of filters for your lists.
    • Various view widgets: lists, master-detail, list of thumbnails etc
    • Select2, Datepicker, DateTimePicker
    • Related Select2 fields.
    • Google charts with automatic group by or direct values and filters.
    • AddOn system, write your own and contribute.
  • CRUD REST API
    • Automatic CRUD RESTful APIs.
    • Internationalization
    • Integration with flask-jwt-extended extension to protect your endpoints.
    • Metadata for dynamic rendering.
    • Selectable columns and metadata keys.
    • Automatic and configurable data validation.
  • Forms
    • Automatic, Add, Edit and Show from Database Models
    • Labels and descriptions for each field.
    • Automatic base validators from model's definition.
    • Custom validators, extra fields, custom filters for related dropdown lists.
    • Image and File support for upload and database field association. It will handle everything for you.
    • Field sets for Form's (Django style).
  • i18n
    • Support for multi-language via Babel
  • Bootstrap 3.1.1 CSS and js, with Select2 and DatePicker
  • Font-Awesome icons, for menu icons and actions.

Some pictures

Login page (with AUTH_DB)

image

Login page (with AUTH_OAUTH)

image

Security

image

Lists:

List contacts example

image

List Group example with search

image

Charts:

Group by pie chart

image

Direct time chart

image

Group by time chart

image

Projects/Organizations using FAB

If you would like to share your project, or let everyone know that you're using FAB on your organization please submit a PR or send me an email with the details.

Projects:

  • Superset - a data exploration platform designed to be visual, intuitive, and interactive
  • Airflow - a platform to programmatically author, schedule, and monitor workflows.

Organizations:

Depends on:

  • flask
  • click
  • colorama
  • flask-sqlalchemy
  • flask-login
  • flask-openid
  • flask-wtform
  • flask-Babel

flask-appbuilder's People

Contributors

abdullahdahmash avatar absinthetized avatar alexandrezia avatar anddam avatar ashb avatar benjreinhart avatar betodealmeida avatar cameronnemo avatar deeagle001 avatar dependabot[bot] avatar dolfandringa avatar dosenpfand avatar dpgaspar avatar fedepad avatar fuzzwah avatar henkvanhoek avatar jak137 avatar jmcarp avatar john-bodley avatar michaelpereira avatar mistercrunch avatar nachtkinder avatar nytai avatar roganw avatar ryanahamilton avatar shixin-guo avatar svchiluvuri avatar vavrusa avatar veflask avatar xiaohanyu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flask-appbuilder's Issues

Need help on revising translations

It would be awesome, if someone could help me on revising the existing translations. I made them with google translate, so they probably are a bit foolish.

Translations are here: https://github.com/dpgaspar/Flask-AppBuilder/tree/master/flask_appbuilder/translations

The framework currently supports (besides English):

  • German
  • Spanish
  • Portuguese
  • Portuguese Brazil
  • Russian
  • Simplified Chinese

Any help on how to proceed, just ask. If your a native speaker of any of the above this should be pretty easy (i hope).

3 Clause BSD and powered by footer

Legally it is impossible to use this project as is with the 3 clause BSD (Clause in question shown below) and the default footer template which has Powered by F.A.B. (dpgaspar).

I would just remove the powered by as it adds traction to the actual usage of the project.

  • Neither the name of the {organization} nor the names of its
    contributors may be used to endorse or promote products derived from
    this software without specific prior written permission.

This is not major just a little weird.

error on quickimages example

When I run $ python run.py in quickimages example, the terminal returns warning
"Filter type not supported for column: photo"

The app still runs, but error in browser on url http://0.0.0.0:8080/persongeneralview/list/

I narrowed the error down to line 28 in models.py
photo = Column(ImageColumn, nullable=False)

I changed "ImageColumn" to "String(150)" … it eliminates the error, but the ImageColumn functionality is not available, of course.

The last call in http://0.0.0.0:8080/persongeneralview/list/ shows error in widgets.py line 59
search_filters[col] = [unicode(flt.name) for flt in dict_filters[col]]


UPDATE

As a temporary fix, I commented out line 59 in widgets.py (noted above), instead of changing "ImageColumn" to "String(150)" (noted above) … this allows me to use the image upload feature.


UPDATE 2

Fix: flask_appbuilder/models/filters.py
line 163: if datamodel.is_text(col) or datamodel.is_string(col) or datamodel.is_image(col):

Added datamodel.is_image(col) to accommodate the extended datatype "ImageColumn"

how to diy widgets?

I want add widget, like a other model data
But, I do not know how to add

Thanks ^_^

[Question] Sum/Avg functions in models

Hi,

First of all: Pretty nice work!

My Question:
Is it possible, to define a Column in a model as a sum of values of another table?

E.g.: I want to track people (by name and birthday) and their scores in events - and I would like to get this scores later as a view

Here is my models.py (abbreviated):

class People(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(50), unique=True, nullable=False)
    birthday = Column(Date)
    #Here something like "score = Column(Integer, sum(result.score))"

class Event(Model);
    id = Column(Integer, primary_key=True)

class SubEvent(Model):
    id = Column(Integer, primary_key=True)
    name = Column(String(50), nullable=False)
    id_event = Column(Integer, ForeignKey('event.id')
    event = relationship('Event')

class Result(Model);
    id = Column(Integer, primary_key=True)
    id_person = Column(Integer, ForeignKey('people.id')
    person = relationship('People')
    id_event = Column(Integer, ForeignKey('event.id'))
    event = relationship('Event')
    id_subevent = Column(Integer, ForeignKey('subevent.id'))
    subevent = relationship("Subevent")
    score = Column(Integer, nullable=False)

Dynamic field filter in select2

Maybe I am not really understanding edit_form_query_rel_fields, but this is a pretty important feature. Build a filter to the drop down list based on the selection of previous drop down lists.

Usecase user select category A from form field 1. User can then only select subsets of category A from form field 2.

Is there an easy way of doing this

PS 0.10 looks rad

Configuration Default View

This seems basic, but I can't find it in the documentation. How can I define the home screen (or root page) for FAB? Right now it just says 'Welcome'. If I could just define the root page (page you go to after login to be a view, that would be great. Maybe a different view depending on if logged in or not.

Thanks.

LDAP user registration and admin user

If you use LDAP and do not set AUTH_USER_REGISTRATION = True, the security manager tries to find the user in the database, but fails and he cannot start a session.

flask_appbuilder/security/manager.py:406

if self.auth_user_registration and user is None:

Would it be reasonable to have AUTH_USER_REGISTRATION default to True when LDAP is in use or document the config section accordingly?

Since I switched to using LDAP, I no longer have an admin user. We can have FAB create those ab_user rows, but they will have role 'Public'. I went into app.db and did an sql update to make myself role_id = 1 (Admin). Is there a less error prone way to do this? I didn't see anything in the documentation. Perhaps one option would be to first use the local db (for exceptions like the admin user) and then LDAP to authenticate users.

thank you!

Initialisation using the app factory pattern, requires application context

If I want to initialise flask-AppBuilder using an application factory pattern I get the standard out of application context error. I can solve this by initialising within the "with app.app_context():", is this continued expected behaviour?

Initialise extensions possibly in a separate file

db = SQLA()
appbuilder = AppBuilder()

Initialise app

app = Flask(name)
app.config.from_object('config')

Initialise extensions

db.init_app(app)
appbuilder.init_app(app, db.session)

Relative link in menu

I'd like to add a link to the 'add' functionality of a view (http://localhost:5000/someview/add) . It seems that when you do add_view it always links to the list, and you can't do multiple add_views to the same view, so it seems the right way to make the link I want is with add_link. I can add:

appbuilder.add_link("Click Here", href="/someview/add", icon="fa-folder-open-o", category="SomeCategory")

and this runs when I run FAB from python in the command line. However, I'm running FAB via uwsgi in a subdirectory: http://my.server.com/fab/ -- so I need the link to be http://my.server.com/fab/someview/add but only when running via uwsgi as this breaks the link when running python on the command line.

Is there a variable I can pass through the href argument so FAB will build the right url? IE:

appbuilder.add_link("Click Here", href="%FAB_BASE%/someview/add", icon="fa-folder-open-o", category="SomeCategory")

Ideally that url will either detect http vs https so stay agnostic to it.

Thanks!

error on form with read only fields

I'm having a hard time figuring this one out. I have a standard view based on ModelView as follows:

class PeerReviewModelView(ModelView):

datamodel = SQLAModel(Study, db.session)
base_filters = [['status_id', FilterEqual, DATA.NEW]]
base_permissions = ['can_list', 'can_show', 'can_edit', 'can_delete']
base_order = ['date_read', 'asc']

list_title = "Pending Peer Reviews"
edit_title = "Score Peer Review"
label_columns = {'errortype': 'Error Type', 'raw_name': 'Name'}
list_columns = ['dob', 'nw_mrn', 'nw_accession', 'site']

show_fieldsets = [
    ('Details', {'fields': ['site']}),
    ('Patient Info', {'fields': ['nw_accession', 'nw_mrn', 'dob', 'raw_name']}),
    ('Scoring', {'fields': ['errortype', 'acuity', 'conspicuity', 'client_notes', 'review_notes']})
    ]

edit_fieldsets = [
    ('Details', {'fields': ['site']}),
    ('Patient Info', {'fields': ['nw_accession', 'nw_mrn', 'dob']}),
    ('Scoring', {'fields': ['errortype', 'acuity', 'conspicuity', 'client_notes', 'review_notes']})
    ]

edit_form_extra_fields = {'site': TextField('Originating Site',
                                    widget=BS3TextFieldROWidget()),
                          'nw_accession': TextField('NW Accession',
                                    widget=BS3TextFieldROWidget()),
                          'nw_mrn': TextField('NW MRN',
                                    widget=BS3TextFieldROWidget()),
                          'dob': TextField('DOB',
                                   widget=BS3TextFieldROWidget()),
                          'client_notes': TextAreaField('Client Notes',
                                    widget=BS3TextAreaFieldROWidget())
                            }

def pre_update(self, item):
    item.status_id = DATA.SCORED
    item.scored_on = datetime.datetime.now()
    item.scored_by_id = g.user.id

It works fine without the extra fields, but when they are implemented, I get an error that seems to involve the related field 'site', which shouldn't be changing value when the form is saved:

File "C:\Users\ms419\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 812, in set
value = self.fire_replace_event(state, dict_, value, old, initiator)
[console ready]

dump()
Local variables in frame

initiator
None
old
Cape Cod
dict_
{'acuity_id': None, 'raw_name': u'DSA', 'site_id': 2, 'site': Cape Cod, }
value
u'Cape Cod'
passive
symbol('PASSIVE_OFF')
state
<sqlalchemy.orm.state.InstanceState object at 0x030DEB30>
pop
False
check_old
None
self
<sqlalchemy.orm.attributes.ScalarObjectAttributeImpl object at 0x02E59D50>

The full stack trace follows below:

Traceback (most recent call last)
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\ms419\venv\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\Users\ms419\venv\lib\site-packages\flask_appbuilder\security\decorators.py", line 21, in wraps
return f(self, _args, *_kwargs)
File "C:\Users\ms419\venv\lib\site-packages\flask_appbuilder\views.py", line 189, in edit
widgets = self._edit(pk)
File "C:\Users\ms419\venv\lib\site-packages\flask_appbuilder\baseviews.py", line 735, in edit
form.populate_obj(item)
File "C:\Users\ms419\venv\lib\site-packages\wtforms\form.py", line 96, in populate_obj
field.populate_obj(obj, name)
File "C:\Users\ms419\venv\lib\site-packages\wtforms\fields\core.py", line 323, in populate_obj
setattr(obj, name, self.data)
File "C:\Users\ms419\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 226, in set
instance_dict(instance), value, None)
File "C:\Users\ms419\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 812, in set
value = self.fire_replace_event(state, dict
, value, old, initiator)
File "C:\Users\ms419\venv\lib\site-packages\sqlalchemy\orm\attributes.py", line 832, in fire_replace_event
state, value, previous, initiator or self.replace_token)
File "C:\Users\ms419\venv\lib\site-packages\sqlalchemy\orm\unitofwork.py", line 84, in set

newvalue_state = attributes.instance_state(newvalue)
AttributeError: 'unicode' object has no attribute '_sa_instance_state'

Am I missing something simple here, or is it a bug?

Form validation with floats and 0

Why does making a 0 in non-nullable field give a validation required field error.
image

*Views:
from flask.ext.appbuilder.models.datamodel import SQLAModel
from app import appbuilder, db
from .models import SimpleModel
from flask.ext.appbuilder import ModelView

db.create_all()

class SimpleView(ModelView):
datamodel = SQLAModel(SimpleModel)

appbuilder.add_view(SimpleView, "Something", icon="fa-folder-open-o", category="Stuff", category_icon='fa-envelope')

*Models

from flask.ext.appbuilder.models.datamodel import SQLAModel
from flask.ext.appbuilder import ModelView , Model
from sqlalchemy import Column, String, Float, DateTime, ForeignKey, Integer,
Unicode, Boolean, Date ,Constraint ,UniqueConstraint ,and_ ,or_

class SimpleModel(Model):

__tablename__ = 'simple_model'

id = Column(Integer, primary_key=True, autoincrement=True)
number = Column(Float, nullable=False, default=0)

PS, I hope me taking a deeper dive into the project can help :)

Issues with LDAP Auth (how to set search base, etc)

I see that Flask-AppBuilder supports ldap but the only documentation I can find for it is at http://flask-appbuilder.readthedocs.org/en/latest/config.html?highlight=ldap which only lists one configuration parameter, AUTH_LDAP_SERVER:

define your ldap server when AUTH_TYPE=2
example:

AUTH_TYPE = 2
AUTH_LDAP_SERVER = “ldap://ldapserver.new“

How do you configure the ldap search base and filter, bind address, etc?

Also, the documentation shows setting the ldap server field with double quotes. I seems this is necessary as using single quotes gives me error. This is confusing as other parameters (AUTH_ROLE_ADMIN for example) are set using single quotes.

I've tried both

AUTH_TYPE = 2
AUTH_LDAP_SERVER = “ldap://localhost“

and

AUTH_TYPE = 2
AUTH_LDAP_SERVER = “ldap://ou=people,dc=example,localhost“

and in both cases, login fails but I a port sniff shows no connection to my ldap server (running on port 389 on 127.0.0.1 / localhost. Any suggestions on how to track down why it isn't connecting to the ldap server? No errors in the python terminal running Flask-AppBuilder. Are there any other settings and/or maybe python modules I need?

Thanks,

Download Zip File Overwrites other Files

Unpacking the zip file in Windows causes multiple file overwrites due to the naming convention used.
Example01:
Charts.png
charts.png

Example 02:
Login.db.png
login.db.png

Sort on Strings?

When I view a table, I get blue hyperlinks on many column that allow me to sort on that view (toggling on click between ascending and descending). But some columns don't have the blue hyperlinks. It seems that String columns are the ones I can't sort, while Date, Boolean and Integer columns are sorta-able. Is this known behavior? If so, what would it take to be able to sort on strings?

Little error

I have noticed that you included this in the header file

<link href="/static/appbuilder/css/themes/" rel="stylesheet">

I am noticing a error in the console,its responding with a status code : 404 NOT FOUND

I think you should enter something like this from the " /static/appbuilder/css/themes/ folder "
<link href="/static/appbuilder/css/themes/amelia.css" rel="stylesheet">
...
...
...
etc
or maybe you wanted to add an option for the theme in the Flask-AppBuilder ?

MSSQL Server

Yesterday I attempted getting appbuilder working using MSSQL server and pymssql as a driver and hit some snags. I will get you more details shortly.

1.) Menu bar disappeared although I could still access all the view via their urls

2.) Got an error when looking at a modelview and requesting a new page.

I am not sure if you have ever tested on MSSQL server.

Phillip

Sort a column with PostgreSql

Hi,
When i define SQLALCHEMY_DATABASE_URI to use PostgreSql and if i try to sort a column i get an ERROR :
ProgrammingError: (ProgrammingError) column "contact.personal_celphone" must appear in the GROUP BY clause or be used in an aggregate function LINE 2: FROM contact ORDER BY personal_celphone asc ^ 'SELECT count(%(param_1)s) AS count_1 \nFROM contact ORDER BY personal_celphone asc' {'param_1': '*'}

Thanks for your ideas.

Marc

Error on masterdetail example, SQLalchemy object has no attribute query

Hi,

Trying to run the masterdetail example I get a long string of errors of 'flask_appbuilder.base: Add permission on menu (or view) error: 'SQLAlchemy' object has no attribute 'query'

Traceback output...

AttributeError
AttributeError: 'SQLAlchemy' object has no attribute 'query'

Traceback (most recent call last)
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1836, in call
return self.wsgi_app(environ, start_response)
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "C:\projects\notpony2\lib\site-packages\flask\app.py", line 1461, in dispatch_request
return self.view_functionsrule.endpoint
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\views.py", line 26, in index
return render_template(self.index_template, appbuilder=self.appbuilder)
File "C:\projects\notpony2\lib\site-packages\flask\templating.py", line 128, in render_template
context, ctx.app)
File "C:\projects\notpony2\lib\site-packages\flask\templating.py", line 110, in _render
rv = template.render(context)
File "C:\projects\notpony2\lib\site-packages\jinja2\environment.py", line 969, in render
return self.environment.handle_exception(exc_info, True)
File "C:\projects\notpony2\lib\site-packages\jinja2\environment.py", line 742, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\index.html", line 1, in top-level template code
{% extends "appbuilder/base.html" %}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\base.html", line 2, in top-level template code
{% import 'appbuilder/baselib.html' as baselib %}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\init.html", line 41, in top-level template code
{% block navbar %}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\init.html", line 43, in block "navbar"
{{ baselib.navbar_block(appbuilder.menu, appbuilder.languages) }}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\baselib.html", line 99, in template
{{ menu_block(menu)}}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\templates\appbuilder\baselib.html", line 21, in template
{% if item1 | is_menu_visible %}
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\filters.py", line 104, in is_menu_visible
return self.security_manager.has_access("menu_access", item.name)
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\security\manager.py", line 362, in has_access
if self.is_item_public(permission_name, view_name):
File "C:\projects\notpony2\lib\site-packages\flask_appbuilder\security\manager.py", line 330, in is_item_public
role = self.get_session.query(Role).filter_by(name=self.auth_role_public).first()
AttributeError: 'SQLAlchemy' object has no attribute 'query'
The debugger caught an exception in your WSGI application. You can now look at the traceback which led to the error.
To switch between the interactive traceback and the plaintext one, you can click on the "Traceback" headline. From the text traceback you can also create a paste of it. For code execution mouse-over the frame you want to debug and click on the console icon on the right side.

You can execute arbitrary Python code in the stack frames and there are some extra helpers available for introspection:

dump() shows all variables in the frame
dump(obj) dumps all that's known about the object

edit_form_query_rel_fields error

update to .0.10.0 produces an error in my views with traceback to forms.py:

_get_func_related_query
_filters = Filters().add_filter_list(sqla, filter_rel_field[2])
TypeError: init() takes at least 2 arguments (1 given)

it's a simple FilterEqual query producing the error

Mass delete

What would be the current easiest way to support mass delete

doing rest queries

I'm trying to figure out doing REST queries to edit data and not finding a lot of documentation / examples. I can do a GET on https://localhost/contactmodelview/json to get a dump of the table in json. But if I want to delete an entry, it seems I need to use the action option. When I try:

http://localhost/contactmodelview/action/delete/1

I get permission denied. Looking at the code, it seems the action needs to match a permission in the permissions table, so I tried

http://localhost/contactmodelview/action/can_delete/1

but that gives me an error:

2014-10-28 14:02:22,673:ERROR:app:Exception on /contactmodelview/action/can_delete/1 [GET]
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python2.7/dist-packages/flask_appbuilder/views.py", line 278, in action
    return action.func(self.datamodel.get(pk))
AttributeError: 'NoneType' object has no attribute 'func'
[pid: 28451|app: 0|req: 127/127] 192.168.0.178 () {52 vars in 1917 bytes} [Tue Oct 28 14:02:22 2014] GET /app/contactmodelview/action/can_delete/1 => generated 291 bytes in 213 msecs (HTTP/1.1 500) 2 headers in 84 bytes (1 switches on core 0)

readonly fields

Is there any way to render a field as readonly without writing a custom form? If not, pointers on creating a custom edit form would be helpful.

Link back not remembering filters

So this is again more of a stylistic/functional issue. It came up when I was doing actual user testing.

So link_back does not remember filters, but link_back_old does. This is in : templates/appbuilder/general/lib.html

Is there any reason for not wanting to use the standard onClick="history.go(-1);return true;" and using a custom url router and loosing all the nicely built url filter strings.

related_views

This might be a SQLAlchemy question, but can you explain how the related_views works? Basically, what kind of db links between the two underlying tables are needed.

I have 3 tables:

class Items(Model):
    id = Column(Integer,primary_key=True)
    serial = Column(Integer,unique=True,nullable=False)
   ...


class ItemNotes(Model):
    id = Column(Integer,primary_key=True)
    serial_id = Column(Integer,ForeignKey('product_serial_log.serial'),nullable=False)    
    serial = relationship("Items")
    ...


class ItemProperies(Model):
    id = Column(Integer,primary_key=True)
    serial_id = Column(Integer,ForeignKey('product_serial_log.serial'),nullable=False)    
    serial = relationship("Items")
    ...

Now I can view Items table and have related views to ItemNotes and ItemProperies. But I'd like to view ItemProperties and have it link to ItemNotes. But if I just put a related view in ItemPropertiesView to ItemNotesView it doesn't make the link. I think the issue is because the link (serial_id) is through a 3rd table and not a direct foreign key. Is there a way to pass how to link the views. Or do I need to add some kind of relationship info in the SQLAlchemy level?

Thanks,

reduce is not in python 3

File "c:\Anaconda3\lib\site-packages\flask_appbuilder\models\base.py", line 90, in _get_attr_value

return reduce(getattr, col.split('.'), item)
NameError: name 'reduce' is not defined

PostgreSQL Security Views not displayed on Flask-AppBuilder

Due this reference: #1 (comment), this is the output from python init_app.py

General _add_permission Error: DB not created?                                                                                                                                                                                                                          [4/5221]
General _add_permission Error: DB not created?
General _add_permission Error: DB not created?
General _add_permission Error: DB not created?
General _add_permission Error: DB not created?
Registering: Security . List Users at /users/list
Menu add_category Erro: Maybe db not created
Menu add_category Erro: Maybe db not created
General _add_permission Error: DB not created?
Registering: Security . List Roles at /roles/list
Menu add_category Erro: Maybe db not created
General _add_permission Error: DB not created?
Registering: Security . Base Permissions at /permissions/list
Menu add_category Erro: Maybe db not created
General _add_permission Error: DB not created?
Registering: Security . Views/Menus at /viewmenus/list
Menu add_category Erro: Maybe db not created
General _add_permission Error: DB not created?
Registering: Security . Permission on Views/Menus at /permissionviews/list
Menu add_category Erro: Maybe db not created
General _add_permission Error: DB not created?
--------------------------
     CREATE DB
--------------------------
--------------------------
 CREATE USER and  ROLES
--------------------------
Traceback (most recent call last):
  File "init_app.py", line 27, in 
    db.session.commit()
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/scoping.py", line 149, in do
    return getattr(self.registry(), name)(*args, **kwargs)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 721, in commit
    self.transaction.commit()
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 354, in commit
    self._prepare_impl()
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 334, in _prepare_impl
    self.session.flush()
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1818, in flush
    self._flush(objects)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1936, in _flush
    transaction.rollback(_capture_exception=True)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/util/langhelpers.py", line 58, in __exit__
    compat.reraise(exc_type, exc_value, exc_tb)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/session.py", line 1900, in _flush
    flush_context.execute()
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 372, in execute
    rec.execute(self)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/unitofwork.py", line 525, in execute
    uow
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 64, in save_obj
    table, insert)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/orm/persistence.py", line 569, in _emit_insert_statements
    execute(statement, params)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 662, in execute
    params)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 761, in _execute_clauseelement
    compiled_sql, distilled_params
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 874, in _execute_context
    context)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 1024, in _handle_dbapi_exception
    exc_info
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 196, in raise_from_cause
    reraise(type(exception), exception, tb=exc_tb)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/base.py", line 867, in _execute_context
    context)
  File "/home/jesus/Deployments/flask_dev/lib/python2.7/site-packages/sqlalchemy/engine/default.py", line 324, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.InternalError: (InternalError) transacción abortada, las órdenes serán ignoradas hasta el fin de bloque de transacción
 'INSERT INTO role (name) VALUES (%(name)s) RETURNING role.id' {'name': 'Admin'}

Trivial typo in docs: as has

In the documentation there is

"something that will serve has an id"

should that be:

"something that will serve as an id"

Navbar not extending

The navbar does not extend when looking beyond the current screen.

I guess I could swap out the navbar template but I think this would be good fix.
image

Python3 error

Very cool project with full bootstrap 3 prettiness.

In the docs there is no mention of python 3 support.

I am guessing something to do with babel. This is once I try to load a page.
TypeError: Unxpected value for identifier: b'en'

run under uwsgi?

it's easy to run flask mini app (single file) under uwsgi directly (without a web server),
and i run FAB Skeleton app in virtualenv easily with python, but when issue:
[venv]# uwsgi --http :8080 --wsgi-file ./fab-skeleton/run.py --callable app
i get error:


ImportError: No module named app
unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):
File "./fab-skeleton/run.py", line 1, in
from app import app
ImportError: No module named app
unable to load app 0 (mountpoint='') (callable not found or import error)


it is with many flask-based web apps there on the web.
what's the problem?

Rendering for printing out on paper

Hi,
The rendering of a view ist pretty strange, when I want to print it out on paper.
This is the view in my Browser:
image
This is the view from the Browser-intern "Print" Window (System-Print is no different).
image

The Default-design with the blue border would be pretty cool on a printed page. Is there something you can do about it?

Trivial grammar typo in docs

The docs contain "you can display a record related lists on tab (default) or on the same page", this seems grammatically unclear.

can i set a relationship's field to search_column?

hi, dpgaspar:
relationship's field to search_column?

in my models:

class HostGroup(Model):
    id = Column(Integer, Sequence('seq_gear_host_group_id'), primary_key = True, nullable = False)
    group_name = Column(String(60), nullable = False)

class Host(Model):
    id = Column(Integer, Sequence('seq_host_id'), primary_key = True, nullable = False)
    host_name = Column(String(20), nullable = False, unique = True)
    host_ip = Column(String(255), nullable = False)
    host_group_id = Column(Integer, ForeignKey(HostGroup.id), nullable = False)

    host_group = relationship(HostGroup, backref='host')

class HostLogin(Model):
    id = Column(Integer, Sequence('seq_host_id'), primary_key = True, nullable = False)
    host_id = Column(Integer, ForeignKey(Host.id), nullable = False)
    host = relationship(Host)
    login = Column(String(20), nullable = False)
    password = Column(String(40), nullable = False)
    home_path = Column(String(255), nullable = False)
    login_attr = Column(String(255), nullable = True)

class Application(Model):
    id = Column(Integer, Sequence('seq_gear_app_id'), primary_key = True, nullable = False)
    app_name = Column(String(60), nullable = False)

class AppDeploy(Model):
    id = Column(Integer, Sequence('seq_gear_app_deploy_id'), primary_key = True, nullable = False)
    app_id = Column(Integer, ForeignKey(Application.id), nullable = False)
    app =  relationship(Application)
    login_id = Column(Integer, ForeignKey(HostLogin.id), nullable = False)
    login = relationship(HostLogin)
    group_id = Column(Integer, ForeignKey(AppGroup.id), nullable = False)
    app_group = relationship(AppGroup)

my views:

class AppDeployAdmin(ModelView):
    datamodel = SQLAModel(AppDeploy, db.session)
    list_columns = ['app', 'app_group', 'login', 'login.host.host_group']
    search_columns = ['app', 'app_group']

now, if i want to search 'login.host.host_group' in AppDeployAdmin, how to set the search_column?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.