resolve conflict
This commit is contained in:
commit
d102eaed9c
|
@ -37,9 +37,10 @@ jobs:
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python ${{ matrix.python-version }}
|
- name: Set up Python ${{ matrix.python-version }}
|
||||||
uses: actions/setup-python@v1
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
python-version: ${{ matrix.python-version }}
|
||||||
|
cache: 'pip'
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import datetime
|
|
||||||
|
|
||||||
import flask
|
import flask
|
||||||
from flask import Blueprint, request, url_for
|
from flask import Blueprint, request, url_for
|
||||||
from flask.views import View
|
from flask.views import View
|
||||||
from flask_login import current_user, login_required
|
from flask_login import current_user, login_required
|
||||||
|
|
||||||
|
from ereuse_devicehub import messages
|
||||||
from ereuse_devicehub.inventory.forms import (AllocateForm, LotDeviceForm,
|
from ereuse_devicehub.inventory.forms import (AllocateForm, LotDeviceForm,
|
||||||
LotForm, NewActionForm,
|
LotForm, NewActionForm,
|
||||||
NewDeviceForm, TagDeviceForm,
|
NewDeviceForm, TagDeviceForm,
|
||||||
|
@ -294,31 +293,42 @@ class TagUnlinkDeviceView(View):
|
||||||
class NewActionView(View):
|
class NewActionView(View):
|
||||||
methods = ['POST']
|
methods = ['POST']
|
||||||
decorators = [login_required]
|
decorators = [login_required]
|
||||||
_form = NewActionForm
|
form_class = NewActionForm
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
self.form = self._form()
|
self.form = self.form_class()
|
||||||
|
|
||||||
next_url = url_for('inventory.devices.devicelist')
|
|
||||||
lot_id = self.form.lot.data
|
|
||||||
if lot_id:
|
|
||||||
next_url = url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
|
|
||||||
|
|
||||||
if self.form.validate_on_submit():
|
if self.form.validate_on_submit():
|
||||||
self.form.save()
|
instance = self.form.save()
|
||||||
|
messages.success('Action "{}" created successfully!'.format(instance.type))
|
||||||
|
|
||||||
|
next_url = self.get_next_url()
|
||||||
return flask.redirect(next_url)
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
def get_next_url(self):
|
||||||
|
lot_id = self.form.lot.data
|
||||||
|
|
||||||
|
if lot_id:
|
||||||
|
return url_for('inventory.devices.lotdevicelist', lot_id=lot_id)
|
||||||
|
|
||||||
|
return url_for('inventory.devices.devicelist')
|
||||||
|
|
||||||
|
|
||||||
class NewAllocateView(NewActionView, DeviceListMix):
|
class NewAllocateView(NewActionView, DeviceListMix):
|
||||||
methods = ['POST']
|
methods = ['POST']
|
||||||
_form = AllocateForm
|
form_class = AllocateForm
|
||||||
|
|
||||||
def dispatch_request(self):
|
def dispatch_request(self):
|
||||||
lot_id = self.form.lot.data
|
self.form = self.form_class()
|
||||||
dispatch = super().dispatch_request()
|
|
||||||
if dispatch:
|
|
||||||
return dispatch
|
|
||||||
|
|
||||||
|
if self.form.validate_on_submit():
|
||||||
|
instance = self.form.save()
|
||||||
|
messages.success('Action "{}" created successfully!'.format(instance.type))
|
||||||
|
|
||||||
|
next_url = self.get_next_url()
|
||||||
|
return flask.redirect(next_url)
|
||||||
|
|
||||||
|
lot_id = self.form.lot.data
|
||||||
self.get_context(lot_id)
|
self.get_context(lot_id)
|
||||||
self.context['form_new_allocate'] = self.form
|
self.context['form_new_allocate'] = self.form
|
||||||
return flask.render_template(self.template_name, **self.context)
|
return flask.render_template(self.template_name, **self.context)
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
from flask import flash, session
|
||||||
|
|
||||||
|
DEBUG = 10
|
||||||
|
INFO = 20
|
||||||
|
SUCCESS = 25
|
||||||
|
WARNING = 30
|
||||||
|
ERROR = 40
|
||||||
|
|
||||||
|
DEFAULT_LEVELS = {
|
||||||
|
'DEBUG': DEBUG,
|
||||||
|
'INFO': INFO,
|
||||||
|
'SUCCESS': SUCCESS,
|
||||||
|
'WARNING': WARNING,
|
||||||
|
'ERROR': ERROR,
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFAULT_TAGS = {
|
||||||
|
DEBUG: 'light',
|
||||||
|
INFO: 'info',
|
||||||
|
SUCCESS: 'success',
|
||||||
|
WARNING: 'warning',
|
||||||
|
ERROR: 'danger',
|
||||||
|
}
|
||||||
|
|
||||||
|
DEFAULT_ICONS = {
|
||||||
|
DEFAULT_TAGS[DEBUG]: 'tools',
|
||||||
|
DEFAULT_TAGS[INFO]: 'info-circle',
|
||||||
|
DEFAULT_TAGS[SUCCESS]: 'check-circle',
|
||||||
|
DEFAULT_TAGS[WARNING]: 'exclamation-triangle',
|
||||||
|
DEFAULT_TAGS[ERROR]: 'exclamation-octagon',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def add_message(level, message):
|
||||||
|
level_tag = DEFAULT_TAGS[level]
|
||||||
|
if '_message_icon' not in session:
|
||||||
|
session['_message_icon'] = DEFAULT_ICONS
|
||||||
|
|
||||||
|
flash(message, level_tag)
|
||||||
|
|
||||||
|
|
||||||
|
def debug(message):
|
||||||
|
"""Add a message with the ``DEBUG`` level."""
|
||||||
|
add_message(DEBUG, message)
|
||||||
|
|
||||||
|
|
||||||
|
def info(message):
|
||||||
|
"""Add a message with the ``INFO`` level."""
|
||||||
|
add_message(INFO, message)
|
||||||
|
|
||||||
|
|
||||||
|
def success(message):
|
||||||
|
"""Add a message with the ``SUCCESS`` level."""
|
||||||
|
add_message(SUCCESS, message)
|
||||||
|
|
||||||
|
|
||||||
|
def warning(message):
|
||||||
|
"""Add a message with the ``WARNING`` level."""
|
||||||
|
add_message(WARNING, message)
|
||||||
|
|
||||||
|
|
||||||
|
def error(message):
|
||||||
|
"""Add a message with the ``ERROR`` level."""
|
||||||
|
add_message(ERROR, message)
|
|
@ -175,6 +175,15 @@
|
||||||
</aside><!-- End Sidebar-->
|
</aside><!-- End Sidebar-->
|
||||||
|
|
||||||
<main id="main" class="main">
|
<main id="main" class="main">
|
||||||
|
{% block messages %}
|
||||||
|
{% for level, message in get_flashed_messages(with_categories=true) %}
|
||||||
|
<div class="alert alert-{{ level}} alert-dismissible fade show" role="alert">
|
||||||
|
<i class="bi bi-{{ session['_message_icon'][level]}} me-1"></i>
|
||||||
|
{{ message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
{% endblock main %}
|
{% endblock main %}
|
||||||
|
|
|
@ -8,7 +8,7 @@ colorama==0.3.9
|
||||||
colour==0.1.5
|
colour==0.1.5
|
||||||
ereuse-utils[naming,test,session,cli]==0.4.0b49
|
ereuse-utils[naming,test,session,cli]==0.4.0b49
|
||||||
Flask==1.0.2
|
Flask==1.0.2
|
||||||
Flask-Cors==3.0.6
|
Flask-Cors==3.0.10
|
||||||
Flask-Login==0.5.0
|
Flask-Login==0.5.0
|
||||||
Flask-SQLAlchemy==2.3.2
|
Flask-SQLAlchemy==2.3.2
|
||||||
Flask-WTF==1.0.0
|
Flask-WTF==1.0.0
|
||||||
|
@ -23,13 +23,13 @@ pytest-runner==4.2
|
||||||
python-dateutil==2.7.3
|
python-dateutil==2.7.3
|
||||||
python-stdnum==1.9
|
python-stdnum==1.9
|
||||||
PyYAML==3.13
|
PyYAML==3.13
|
||||||
requests[security]==2.19.1
|
requests[security]==2.27.1
|
||||||
requests-mock==1.5.2
|
requests-mock==1.5.2
|
||||||
SQLAlchemy==1.2.17
|
SQLAlchemy==1.2.17
|
||||||
SQLAlchemy-Utils==0.33.11
|
SQLAlchemy-Utils==0.33.11
|
||||||
teal==0.2.0a38
|
teal==0.2.0a38
|
||||||
webargs==4.0.0
|
webargs==5.5.3
|
||||||
Werkzeug==0.14.1
|
Werkzeug==0.15.3
|
||||||
sqlalchemy-citext==1.3.post0
|
sqlalchemy-citext==1.3.post0
|
||||||
flask-weasyprint==0.5
|
flask-weasyprint==0.5
|
||||||
weasyprint==44
|
weasyprint==44
|
||||||
|
|
Reference in New Issue