Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keeup #1

Merged
merged 41 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
7bf1fc6
Improved test code coverage
PanderMusubi Mar 19, 2023
f645cd6
add open collective shield
PanderMusubi Mar 22, 2023
708c14a
additional pypi links
PanderMusubi Mar 22, 2023
8a6b54e
Fix #268. Allow table actions when data is provided using non-SQLAlch…
nickovs Mar 24, 2023
ab14578
Merge pull request #282 from PanderMusubi/pypilinks
greyli Apr 4, 2023
c49674c
Merge pull request #283 from PanderMusubi/shieldopencollective
greyli Apr 4, 2023
2414daa
Merge pull request #277 from PanderMusubi/codecov
greyli Apr 4, 2023
aa3dd43
Added a variation of the table action test case to test actions when …
nickovs Apr 4, 2023
1b85064
Improve tests & update changelog
greyli Apr 4, 2023
22374ff
Merge pull request #284 from nickovs/fix-268-table-actions-with-dicts
greyli Apr 4, 2023
1edb922
upgraded icons to version 1.10.4
PanderMusubi Apr 4, 2023
dc0b91e
render enum in table (#271)
PanderMusubi Apr 5, 2023
7e13b7d
Fix typo in CHANGES.rst
cthoyt Apr 28, 2023
281c042
upgraded icons to version 1.10.5
PanderMusubi Apr 28, 2023
f4f34d5
upgraded ip address demo bootstrap 5
PanderMusubi Apr 28, 2023
f7d1481
Address flask.Markup deprecation in Flask 2.3
guidoiaquinti May 4, 2023
a2f3165
Merge pull request #292 from cthoyt/patch-1
greyli May 13, 2023
aa2daed
Merge pull request #294 from PanderMusubi/demo_ip
greyli May 13, 2023
c328eac
Merge pull request #289 from PanderMusubi/icons_1_10_4
greyli May 13, 2023
ed59d2a
Merge pull request #296 from guidoiaquinti/master
greyli May 13, 2023
2819d6a
list total number of suppported icons
PanderMusubi May 17, 2023
062cde7
Merge pull request #297 from PanderMusubi/icons-count
greyli Jun 11, 2023
e47e691
upgrade bootstrap 5.3.0
PanderMusubi May 30, 2023
13419d8
Merge pull request #301 from PanderMusubi/bootstrap53
greyli Jul 23, 2023
c750b17
Update requirement files
greyli Jul 23, 2023
da6143c
Test against Python 3.11
greyli Jul 23, 2023
e44dec0
Upgrade popper to 2.11.8
greyli Jul 23, 2023
4c3c1fd
Merge pull request #303 from helloflask/upgrade-req
greyli Jul 23, 2023
747675d
Disable codecov comment
greyli Jul 23, 2023
974b3ba
Merge pull request #304 from helloflask/codecov-comment
greyli Jul 23, 2023
0f16906
Fix incorrect Bootstrap JS integrity
greyli Jul 24, 2023
50ddbce
Merge pull request #305 from helloflask/fix-bs-js-integrity
greyli Jul 24, 2023
b430738
Release 2.3.0
greyli Jul 24, 2023
c28d5d3
Work on 2.3.1
greyli Jul 24, 2023
64b40e1
fix icons count
PanderMusubi Jul 24, 2023
0533edb
Merge pull request #307 from PanderMusubi/fix-icons-count
greyli Aug 9, 2023
6cd4ef8
upgrade bootstrap and bootswatch to 5.3.1
PanderMusubi Jul 26, 2023
02093bf
Merge pull request #310 from PanderMusubi/bootstrap-531
greyli Sep 17, 2023
a515fa5
Bootstrap 5.3.2 and Icons 1.11.1 (#319)
PanderMusubi Sep 21, 2023
00441f3
Replace deprecated decorator before_first_request
PanderMusubi Sep 18, 2023
85dd170
Merge pull request #320 from PanderMusubi/before_first_request
greyli Sep 22, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.7', '3.8', '3.9', '3.10']
python: ['3.8', '3.9', '3.10', '3.11']
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
Expand Down
16 changes: 14 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
Changelog
=========

2.3.1
-----

Release date: -

- Upgrade to Bootstrap 5.3.2, Bootswatch 5.3.1, and Bootstrap Icons 1.11.1.


2.3.0
-----

Release date: -
Release date: 2023/7/24

- Drop Python 3.7 support, and test against Python 3.11.
- Render enums in tables by their labels.
- Support creating action URLs for dict data (`#268 <https://github.com/helloflask/bootstrap-flask/issues/268>`__).
- Upgrade to Bootstrap 5.3.0, Bootstrap Icons 1.10.5, and Popper 2.11.8.


2.2.0
Expand Down Expand Up @@ -46,7 +58,7 @@ Release date: 2022/2/27

Release date: 2022/1/27

- Remove extra quotaion mark in ``render_nav_item``
- Remove extra quotation mark in ``render_nav_item``
(`#201 <https://github.com/helloflask/bootstrap-flask/pull/201>`__).
- Fix signature of ``Bootstrap.__init__()`` incompatible with older version
(`#198 <https://github.com/helloflask/bootstrap-flask/pull/198>`__).
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Current version on PyPI](https://img.shields.io/pypi/v/bootstrap-flask)](https://pypi.org/project/bootstrap-flask/)
[![Build status](https://github.com/helloflask/bootstrap-flask/workflows/build/badge.svg)](https://github.com/helloflask/bootstrap-flask/actions)
[![Coverage Status](https://coveralls.io/repos/github/helloflask/bootstrap-flask/badge.svg?branch=master)](https://coveralls.io/github/helloflask/bootstrap-flask?branch=master)
[![Open Collective](https://img.shields.io/opencollective/all/bootstrap-flask)](https://opencollective.com/bootstrap-flask)

Bootstrap-Flask is a collection of Jinja macros for Bootstrap 4 & 5 and Flask. It helps you to
render Flask-related data and objects to Bootstrap markup HTML more easily:
Expand Down Expand Up @@ -79,7 +80,7 @@ docs for more details.

Live demos of the latest release are:
- [Examples with Bootstrap 4](http://173.212.198.217/)
- [Examples with Bootstrap 5](http://173.212.227.186/)
- [Examples with Bootstrap 5](http://109.205.179.12/)


## Donate
Expand Down
2 changes: 2 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
comment: false

27 changes: 16 additions & 11 deletions docs/macros.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ API
:param horizontal_columns: When using the horizontal layout, layout forms
like this. Must be a 3-tuple of ``(column-type,
left-column-size, right-column-size)``.
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
secondary, outline-success, etc.), default to ``primary`` (e.g. ``btn-primary``). This will
overwrite config ``BOOTSTRAP_BTN_STYLE``.
:param button_size: Set button size for ``SubmitField``. Accept Bootstrap button size name: sm, md, lg, block,
Expand Down Expand Up @@ -181,7 +181,7 @@ API
:param enctype: ``<form>`` enctype attribute. If ``None``, will
automatically be set to ``multipart/form-data`` if a
:class:`~wtforms.fields.FileField` or :class:`~wtforms.fields.MultipleFileField` is present in the form.
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
secondary, outline-success, etc.), default to ``primary`` (e.g. ``btn-primary``). This will
overwrite config ``BOOTSTRAP_BTN_STYLE``.
:param button_size: Set button size for ``SubmitField``. Accept Bootstrap button size name: sm, md, lg, block,
Expand Down Expand Up @@ -274,7 +274,7 @@ API
if nothing more specific is said for the div column of the rendered field.
:param col_map: A dictionary, mapping field.name to a class definition that should be applied to
the div column that contains the field. For example: ``col_map={'username': 'col-md-2'})``.
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
:param button_style: Set button style for ``SubmitField``. Accept Bootstrap button style name (i.e. primary,
secondary, outline-success, etc.), default to ``primary`` (e.g. ``btn-primary``). This will
overwrite config ``BOOTSTRAP_BTN_STYLE``.
:param button_size: Set button size for ``SubmitField``. Accept Bootstrap button size name: sm, md, lg, block,
Expand Down Expand Up @@ -447,11 +447,12 @@ When you call ``flash('message', 'category')``, there are 8 category options ava

primary, secondary, success, danger, warning, info, light, dark.

If you want to use HTML in your message body, just wrapper your message string with ``flask.Markup`` to tell Jinja it's safe:
If you want to use HTML in your message body, just wrapper your message string with ``markupsafe.Markup`` to tell Jinja it's safe:

.. code-block:: python

from flask import flash, Markup
from flask import flash
from markupsafe import Markup

@app.route('/test')
def test():
Expand Down Expand Up @@ -496,7 +497,7 @@ API
urlize_columns=None,\
show_actions=False,\
actions_title='Actions',\
model=None,\
model=None,\
custom_actions=None,\
view_url=None,\
edit_url=None,\
Expand All @@ -519,7 +520,9 @@ API
using ``|urlize``. Is overruled by ``safe_columns`` parameter. Default is ``None``.
WARNING: Only use this for sanitized user data to prevent XSS attacks.
:param show_actions: Whether to display the actions column. Default is ``False``.
:param model: The model used to build custom_action, view, edit, delete URLs.
:param model: An optional model used to build custom_action, view, edit,
delete URLs. Set this if you need to pull the URL arguments from
a different SQLAlchemy class indexed with the same primary key.
:param actions_title: Title for the actions column header. Default is ``'Actions'``.
:param custom_actions: A list of tuples for creating custom action buttons, where each tuple contains
('Title Text displayed on hover', 'bootstrap icon name', 'URL tuple or fixed URL string')
Expand All @@ -541,8 +544,10 @@ an URL tuple in the form of ``('endpoint', [('url_parameter_name', ':db_model_fi
it's a variable, otherwise it will becomes a fixed value). ``db_model_fieldname`` may also contain dots to access
relationships and their fields (e.g. ``user.name``).

Remember to set the ``model`` when setting this URLs, so that Bootstrap-Flask will know where to get the actual value
when building the URL.
By default, Bootstrap-Flask will take the fields from the row data provided.
Alternatively, you may set the ``model``, in which case a record from that
model, indexed with the same primary key, will be used to get the actual
value when building the URL.

For example, for the view below:

Expand All @@ -563,13 +568,13 @@ Here is the full example:
@app.route('/test')
def test():
data = Message.query.all()
return render_template('test.html', data=data, Message=Message)
return render_template('test.html', data=data)

.. code-block:: jinja

{% from 'bootstrap4/table.html' import render_table %}

{{ render_table(data, model=Message, view_url=('view_message', [('message_id', ':id')])) }}
{{ render_table(data, view_url=('view_message', [('message_id', ':id')])) }}

The following arguments are expect to accpet an URL tuple:

Expand Down
2 changes: 1 addition & 1 deletion examples/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Now go to http://localhost:5000.
Live demos of the latest release are:

- `Examples with Bootstrap 4 <http://173.212.198.217/>`_
- `Examples with Bootstrap 5 <http://173.212.227.186/>`_
- `Examples with Bootstrap 5 <http://109.205.179.12/>`_

Overview of icons
-----------------
Expand Down
17 changes: 12 additions & 5 deletions examples/bootstrap4/app.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# -*- coding: utf-8 -*-
from flask import Flask, render_template, request, flash, Markup, redirect, url_for
from enum import Enum
from flask import Flask, render_template, request, flash, redirect, url_for
from markupsafe import Markup
from flask_wtf import FlaskForm, CSRFProtect
from wtforms.validators import DataRequired, Length, Regexp
from wtforms.fields import *
Expand Down Expand Up @@ -121,17 +123,21 @@ class BootswatchForm(FlaskForm):
submit = SubmitField()


class MyCategory(Enum):
CAT1 = 'Category 1'
CAT2 = 'Category 2'


class Message(db.Model):
id = db.Column(db.Integer, primary_key=True)
text = db.Column(db.Text, nullable=False)
author = db.Column(db.String(100), nullable=False)
category = db.Column(db.String(100), nullable=False)
category = db.Column(db.Enum(MyCategory), default=MyCategory.CAT1, nullable=False)
draft = db.Column(db.Boolean, default=False, nullable=False)
create_time = db.Column(db.Integer, nullable=False, unique=True)


@app.before_first_request
def before_first_request_func():
with app.app_context():
db.drop_all()
db.create_all()
for i in range(20):
Expand All @@ -151,9 +157,10 @@ def before_first_request_func():
m = Message(
text=f'Message {i+1} {url}',
author=f'Author {i+1}',
category=f'Category {i+1}',
create_time=4321*(i+1)
)
if i % 2:
m.category = MyCategory.CAT2
if i % 4:
m.draft = True
db.session.add(m)
Expand Down
Loading