Merge pull request #376 from eReuse/feature/3854-new-button-transfer
add new buttons for transfer
This commit is contained in:
commit
fbf70aac89
|
@ -1275,14 +1275,14 @@ class TransferForm(FlaskForm):
|
|||
def __init__(self, *args, **kwargs):
|
||||
self._type = kwargs.get('type')
|
||||
lot_id = kwargs.pop('lot_id', None)
|
||||
self._tmp_lot = Lot.query.filter(Lot.id == lot_id).one()
|
||||
self._tmp_lot = None
|
||||
if lot_id:
|
||||
self._tmp_lot = Lot.query.filter(Lot.id == lot_id).one()
|
||||
super().__init__(*args, **kwargs)
|
||||
self._obj = None
|
||||
|
||||
def validate(self, extra_validators=None):
|
||||
is_valid = super().validate(extra_validators)
|
||||
if not self._tmp_lot:
|
||||
return False
|
||||
|
||||
if self._type and self.type.data not in ['incoming', 'outgoing']:
|
||||
return False
|
||||
|
@ -1303,8 +1303,12 @@ class TransferForm(FlaskForm):
|
|||
return self._obj
|
||||
|
||||
def set_obj(self):
|
||||
self.newlot = Lot(name=self._tmp_lot.name)
|
||||
self.newlot.devices = self._tmp_lot.devices
|
||||
name = self.code.data
|
||||
if self._tmp_lot:
|
||||
name = self._tmp_lot.name
|
||||
self.newlot = Lot(name=name)
|
||||
if self._tmp_lot:
|
||||
self.newlot.devices = self._tmp_lot.devices
|
||||
db.session.add(self.newlot)
|
||||
|
||||
self._obj = Transfer(lot=self.newlot)
|
||||
|
|
|
@ -753,7 +753,7 @@ class NewTransferView(GenericMixin):
|
|||
form_class = TransferForm
|
||||
title = "Add new transfer"
|
||||
|
||||
def dispatch_request(self, lot_id, type_id):
|
||||
def dispatch_request(self, type_id, lot_id=None):
|
||||
self.form = self.form_class(lot_id=lot_id, type=type_id)
|
||||
self.get_context()
|
||||
|
||||
|
@ -1355,6 +1355,10 @@ devices.add_url_rule(
|
|||
)
|
||||
devices.add_url_rule(
|
||||
'/lot/<string:lot_id>/transfer/<string:type_id>/',
|
||||
view_func=NewTransferView.as_view('lot_new_transfer'),
|
||||
)
|
||||
devices.add_url_rule(
|
||||
'/lot/transfer/<string:type_id>/',
|
||||
view_func=NewTransferView.as_view('new_transfer'),
|
||||
)
|
||||
devices.add_url_rule(
|
||||
|
|
|
@ -194,6 +194,11 @@
|
|||
{% else %}
|
||||
<ul id="incoming-lots-nav" class="nav-content collapse" data-bs-parent="#sidebar-nav">
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="{{ url_for('inventory.new_transfer', type_id='incoming') }}">
|
||||
<i class="bi bi-plus" style="font-size: larger;"></i><span>New Incoming lot</span>
|
||||
</a>
|
||||
</li>
|
||||
{% for lot in lots %}
|
||||
{% if lot.is_incoming %}
|
||||
<li>
|
||||
|
@ -219,6 +224,11 @@
|
|||
{% else %}
|
||||
<ul id="outgoing-lots-nav" class="nav-content collapse " data-bs-parent="#sidebar-nav">
|
||||
{% endif %}
|
||||
<li>
|
||||
<a href="{{ url_for('inventory.new_transfer', type_id='outgoing') }}">
|
||||
<i class="bi bi-plus" style="font-size: larger;"></i><span>New Outgoing lot</span>
|
||||
</a>
|
||||
</li>
|
||||
{% for lot in lots %}
|
||||
{% if lot.is_outgoing %}
|
||||
<li>
|
||||
|
|
|
@ -47,10 +47,10 @@
|
|||
{% if lot.is_temporary or not lot.transfer.closed %}
|
||||
|
||||
{% if lot and lot.is_temporary %}
|
||||
<a type="button" href="{{ url_for('inventory.new_transfer', lot_id=lot.id, type_id='outgoing') }}" class="btn btn-primary doTransfer" >
|
||||
<a type="button" href="{{ url_for('inventory.lot_new_transfer', lot_id=lot.id, type_id='outgoing') }}" class="btn btn-primary doTransfer" >
|
||||
Create Outgoing Lot
|
||||
</a>
|
||||
<a type="button" href="{{ url_for('inventory.new_transfer', lot_id=lot.id, type_id='incoming') }}" class="btn btn-primary doTransfer">
|
||||
<a type="button" href="{{ url_for('inventory.lot_new_transfer', lot_id=lot.id, type_id='incoming') }}" class="btn btn-primary doTransfer">
|
||||
Create Incoming Lot
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -68,6 +68,7 @@ def test_api_docs(client: Client):
|
|||
'/inventory/lot/{lot_id}/trade-document/add/',
|
||||
'/inventory/lot/{lot_id}/transfer/{type_id}/',
|
||||
'/inventory/lot/{lot_id}/transfer/',
|
||||
'/inventory/lot/transfer/{type_id}/',
|
||||
'/inventory/lot/{lot_id}/upload-snapshot/',
|
||||
'/inventory/snapshots/{snapshot_uuid}/',
|
||||
'/inventory/snapshots/',
|
||||
|
|
Reference in a new issue