- 14 Aug, 2013 1 commit
-
-
Florian Sachs authored
* New helper-function `contrib.sqla.tools.has_multiple_pks(model)` * The unique validator is only added to the primary key column in `converter()`, when the model does not have multiple primary keys. * Removed option `form_excluded_pk_columns_from_unique_validation` * documentation updated * example updated
-
- 13 Aug, 2013 3 commits
-
-
Florian Sachs authored
Flask-Admin can now handle multiple primary keys to some extent. `get_primary_key()` and `get_pk_value()` where the simple, but important changes. When building the url in `list.html` via `url_for` a url with multiple `&id=x&id=y` is built. As the order as preserved and the request args are from type `werkzeug.datastructures.MultiDict`, the multiple PKs can be grabbed in the correct order an push into `get_one()` which actually has no problems with multiple keys, as sqlalchemy's `query.get()` works exactely in this way. * `contrib.sqla.tools.get_primary_key()` returns a tuple of all primary keys, if there are more than one PKs * `contrib.sqla.view.get_pk_value()` returns a tuple with the values of all primary keys, if there are more than one PKs * `model.helper.get_mdict_item_or_list()` return the single item of a given MultiDict for the given key or the whole list of items, if there are more than one. * `model.base.BaseModelView.[edit_view|delete_view]` can work with a single *id* or multiple ones, by using `get_mdict_item_or_list()` * New option `form_excluded_pk_columns_from_unique_validation` for `model.base.BaseModelView` including docstring. * Option is evaluated in `contrib.sqla.form.AdminModelConverter.()` Tests and documentation is included. An example file showing the feature is in `sqla/examples/multiplepk.py` The changes itself are very small, although it took me hours to go there - the MultiDict saved me! I will change my app I am currently working on to multiple primary keys this week and will push updates if necessary.
-
Serge S. Koval authored
process inherited primary keys correctly
-
Florian Sachs authored
Two new functions on `contrib.sql.tools`: - `is_inherited_primary_key(prop)` : Returns True if the `ColumnProperty` **prop** is an inherited primary key. Occuring Exceptions are not handled but raised. *Should* work with arbitrary levels of inheritance. - `get_column_for_current_model(prop)` : Return the `Column` that belongs to the model of the `ColumnProperty` **prop**. So if the ColumnProperty is for the parent, the Column for the parent ist returned. If the ColumnProperty if for the Child, the Column for the child is returned. Works with arbitrary levels of inheritance. `AdminModelConverter.convert()` and `ModelView.scaffold_list_columns()` are adapted to use the new functions.
-
- 12 Aug, 2013 1 commit
-
-
Florian Sachs authored
When using joined table inheritance (http://docs.sqlalchemy.org/en/latest/orm/inheritance.html), it is common practice to name the pk-property the same like the pk-property of the parent. The child-property ist a pk itself and has a foreign-key relationship to the pk-property of the parent. Example: class BaseWahl(Model): __tablename__ = 'basewahlen' id = Column(Integer, primary_key=True, autoincrement=True) discriminator = db.Column(db.String(50)) __mapper_args__ = { 'polymorphic_identity':'basewahl', 'polymorphic_on': discriminator } class Wahl(BaseWahl): __tablename__ = 'wahlen' id = Column(Integer, ForeignKey('basewahlen.id'), primary_key=True) __mapper_args__ = { 'polymorphic_identity':'wahl', } `AdminModelConverter.convert()` does not allow Properties with multiple columns, but will raise a `TypeError`. I changed it into the following way: - If - more than 1 column for the property - all columns are primary keys - only *one* does not have a Foreign key - only one column corresponds to the current model - select the column, that corresponds to the current model I applied the same code to `ModelView.scaffold_list_columns()` and extended it, the primary key in this special constellation actually is *not* ignored, even if it has a foreign key property, so it can be displayed using `column_display_pk = True`. This solution actually works for me. I do not have enough insight into *Flask-Admin* and definitely even less into *sqlalchemy* to think my solution is the correct one for every situation, but it may be something to think about.
-
- 07 Aug, 2013 1 commit
-
-
Serge S. Koval authored
-
- 06 Aug, 2013 1 commit
-
-
Serge S. Koval authored
-
- 05 Aug, 2013 12 commits
-
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
- 04 Aug, 2013 3 commits
-
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
- 31 Jul, 2013 1 commit
-
-
Serge S. Koval authored
Fixed #273
-
- 30 Jul, 2013 3 commits
-
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
- 28 Jul, 2013 8 commits
-
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
Serge S. Koval authored
-
- 26 Jul, 2013 1 commit
-
-
Serge S. Koval authored
-
- 24 Jul, 2013 2 commits
-
-
Serge S. Koval authored
Fixed #264. Now it is possible to delete files/images in MongoEngine backend. Also improved Save and Continue
-
Serge S. Koval authored
-
- 23 Jul, 2013 2 commits
-
-
Serge S. Koval authored
-
Serge S. Koval authored
-
- 22 Jul, 2013 1 commit
-
-
Serge S. Koval authored
-