Commit Graph

2284 Commits

Author SHA1 Message Date
Oliver
653dcd4526
Annotate "in_stock" quantity to SupplierPart API (#3335)
* Annotate "in_stock" quantity to SupplierPart API

* Increment API version
2022-07-15 17:37:02 +10:00
Oliver
2635327c51
Add 'refresh' button for part parameter table (#3329)
* Add 'refresh' button for part parameter table

* Override default URL behaviour for unit test

(cherry picked from commit 2c12a69529)
2022-07-15 11:55:39 +10:00
Oliver
648faf4ed2
Reference fields (#3267)
* Adds a configurable 'reference pattern' to the IndexingReferenceMixin class

* Expand tests for reference_pattern validator:

- Prevent inclusion of illegal characters
- Prevent multiple groups of hash (#) characters
- Add unit tests

* Validator now checks for valid strftime formatter

* Adds build order reference pattern

* Adds function for creating a valid regex from the supplied pattern

- More unit tests
- Use it to validate BuildOrder reference field

* Refactoring the whole thing again - try using python string.format

* remove datetime-matcher from requirements.txt

* Add some more formatting helper functions

- Construct a regular expression from a format string
- Extract named values from a string, based on a format string

* Fix validator for build order reference field

* Adding unit tests for the new format string functionality

* Adds validation for reference fields

* Require the 'ref' format key as part of a valid reference pattern

* Extend format extraction to allow specification of integer groups

* Remove unused import

* Fix requirements

* Add method for generating the 'next' reference field for a model

* Fix function for generating next BuildOrder reference value

- A function is required as class methods cannot be used
- Simply wraps the existing class method

* Remove BUILDORDER_REFERENCE_REGEX setting

* Add unit test for build order reference field validation

* Adds unit testing for extracting integer values from a reference field

* Fix bugs from previous commit

* Add unit test for generation of default build order reference

* Add data migration for BuildOrder model

- Update reference field with old prefix
- Construct new pattern based on old prefix

* Adds unit test for data migration

- Check that the BuildOrder reference field is updated as expected

* Remove 'BUILDORDER_REFERENCE_PREFIX' setting

* Adds new setting for SalesOrder reference pattern

* Update method by which next reference value is generated

* Improved error handling in api_tester code

* Improve automated generation of order reference fields

- Handle potential errors
- Return previous reference if something goes wrong

* SalesOrder reference has now been updated also

- New reference pattern setting
- Updated default and validator for reference field
- Updated serializer and API
- Added unit tests

* Migrate the "PurchaseOrder" reference field to the new system

* Data migration for SalesOrder and PurchaseOrder reference fields

* Remove PURCHASEORDER_REFERENCE_PREFIX

* Remove references to SALESORDER_REFERENCE_PREFIX

* Re-add maximum value validation

* Bug fixes

* Improve algorithm for generating new reference

- Handle case where most recent reference does not conform to the reference pattern

* Fixes for 'order' unit tests

* Unit test fixes for order app

* More unit test fixes

* More unit test fixing

* Revert behaviour for "extract_int" clipping function

* Unit test value fix

* Prevent build order notification if we are importing records
2022-07-11 00:01:46 +10:00
Matthias Mair
e314e879da
Fix broken copy (#3314)
* update clipboard version

* attach clipboard to about model

* make definition simpler

* make version text copyable
2022-07-09 12:49:53 +10:00
Matthias Mair
4b0b76ecc5
Make "confirm" buttons a user-configurable option. (#3313)
* Make "confirm" buttons a user-configurable option.
Add a new setting to enable the confirm button
Fixes #3069

* Add seperator
2022-07-09 10:28:52 +10:00
Oliver
8f10bbb7e1
BOM Table Improvements (#3310)
* Bug fix for "multi delete" form

- Was requesting entire LIST endpoint before launching form
- Could cause extremely long delays before window opened

* Improve rendering of "no stock available" in BOM table

* Adds footer row to BOM table

- Display total number of parts
- Display minimum "can build" amount

* Added extra information to footer row

* Annotate 'ordering' quantity to BOM list

- Display this quantity in the BOM table

* Bump API version

* JS linting

* Allow BOM list to be filtered by "on_order" parameter

* Add information showing amount that can be built once orders are received
2022-07-08 14:13:00 +10:00
Oliver
cc8238b790
Allow BOM table to be filtered by "stock available" parameter (#3301)
* Allow BOM table to be filtered by "stock available" parameter

* Update API version info

* PEP fixes
2022-07-06 15:28:44 +10:00
Oliver
1235d47eca
Bug fix for sales order allocation table (#3295)
- Display serial number where available
2022-07-05 17:00:25 +10:00
Oliver
5045f85346
Optionally show/hide the "accept_overallocated" dialog option (#3290) 2022-07-04 12:51:51 +10:00
Oliver
fd03b4068d
Fix table sorting issues (#3289)
- Recent update changed default table pagination to "server"
- This broke at least the BOM table, maybe others
- Revert the behaviour to previous to observe old defaults
- Update pagination mode for attachment tables specifically
2022-07-04 12:06:56 +10:00
Oliver
454760ed57
Fix spelling error (#3288)
immediatly -> immediately
2022-07-04 10:04:57 +10:00
Oliver
1184ca06ac
Allows sorting of attachments by 'upload date' (#3275) 2022-07-01 12:00:21 +10:00
Oliver
73445b4b79
Add confirmation for "over-allocated" stock when completing BuildOrder (#3272) 2022-06-29 14:59:55 +10:00
Oliver
8f92fddd2d
Virtual part fix (#3265)
* Add 'virtual': False requirement to sales order items

* Adds "virtual" filter for part table

* Adds extra validation to the SalesOrderLineItem model

* Prevent creation of stock items for virtual parts

- Add validation check to clean() method of StockItem model
- Improve validation message for StockItemSerializer class

* Hide "new stock item" button for virtual parts

* Hide more buttons for 'virtual' parts
2022-06-28 13:39:27 +10:00
Oliver
ad57ca5ddf
Adds notification when items are received against a purcahse order (#3259) 2022-06-27 07:30:38 +10:00
Oliver
b13e12b7bd
Adds a template for handling 403 errors due to CSRF issues (#3260) 2022-06-26 18:09:58 +10:00
Oliver
8c6e3db774
Bug fix for field validation on child forms (#3258)
* Bug fix for field validation on child forms

- If a child form is launched which conatins numerical inputs, field validation fails
- Not taking the "level" parameter into account when looking for the field

* trim long description strings in modal forms
2022-06-26 12:25:42 +10:00
Oliver
b2e31e3474
Notify users when a build order is completed (#3255) 2022-06-26 09:25:37 +10:00
Oliver
16ac1d97f7
Remove custom javascript from auth pages (#3250)
* Remove custom javascript from auth pages

- Unauthorized user cannot load these scripts
- Simply throws console errors

* Split basic "show message" function out into new js file

* Split more generic functions out into new .js file

* javascript linting fix
2022-06-25 07:45:50 +10:00
Oliver
4268130669
Small visual tweaks to various auth views (#3238) 2022-06-23 07:09:17 +10:00
Oliver
652e6fb83e
Sales order tables (#3225)
* Add buttons to expand / collapse shipment tables

(cherry picked from commit 0af9fc473e)

* Updates for sales order lines table

(cherry picked from commit d99ec062ad)
2022-06-18 22:22:00 +10:00
Oliver
eb255e84d8
Small UI improvements to the settings interface (#3223) 2022-06-18 17:33:59 +10:00
Oliver
12fcccb5a6
Fix API endpoint permission for the "AttachmentMixin" class (#3218)
* Fix API endpoint permission for the "AttachmentMixin" class

- Any authenticated user could perform CREATE and UPDATE operations on attachments
- Could be performed via the browsable DRF API
- Could also be performed via the front-end (with some advaned jiggering of OPTIONS code)

* Show or hide buttons depending on the permissions of the user

* Add shortcut for table permission check
2022-06-18 14:48:09 +10:00
Oliver
74bec86675
Part page loading improvements (#3185)
* Lazy load the pricing bom table when the "pricing" tab is selected

* Update django-debug-toolbar configuration

* Major refactoring for the 'can_build' function

- Use a single annotated query to the db, rather than a for loop (which is what a caveman would use)
- Query performance is greatly improved
- Also refactors existing variant-part-stock subquery code, to make it re-usable

* Use minified JS and CSS where possible

* Render a 'preview' version of each part image

- Saves load time when the image is quite large
- Adds a data migration to render out the new variation

* Adds 'preview' version of company images

* Defer loading of javascript files

Note: some cannot be deferred - jquery in particular

* Crucial bugfix for user roles context

- Previously was *not* being calculated correctly
- A non-superuser role would most likely display pages incorrectly

* Prevent loading of "about" on every page

- Load dynamically when requested
- Takes ~400ms!
- Cuts out a lot of fat

* Match displayed image size to preview image size

* Utilize caching framework for accessing user "role" information

- Reduces number of DB queries required by rendering framework

* Remove redundant query elements

* Remove 'stock' field from PartBrief serializer

- A calculated field on a serializer is a *bad idea* when that calculation requires a DB hit

* Query improvements for StockItem serializer

- Remove calculated fields
- Fix annotations

* Bug fixes

* Remove JS load test

- Loading of JS files is now deferred, so the unit test does not work as it used to

* Fix broken template for "maintenance" page

* Remove thumbnail generation migrations

- Already performed manually as part of ''invoke migrate"
- Running as a migration causes unit test problems
- Not sensible to run this as a data-migration anyway

* tweak for build table
2022-06-17 21:26:28 +10:00
Oliver
0d01ea2f2e
Auth forms fix (#3214)
* Improvement and consolidation of various auth forms

* Update "disable 2FA" page to use form fields

Note: Requires merging of https://github.com/valohai/django-allauth-2fa/pull/135

* Update django-allauth-2fa requirements
2022-06-17 11:33:45 +10:00
Jonas Otto
136924cd3f
fix docs link for "email settings not configured" warning (#3209) 2022-06-17 08:14:40 +10:00
Oliver
d84b67ddf4
Label dpi config (#3208)
* Updates for label printing settings:

- Make LABEL_ENABLE a global setting
- Add LABEL_DPI setting (default = 300)
- Add new global settings tab

* Use the configured DPI when printing labels
2022-06-16 14:49:17 +10:00
Oliver
9bd62f986f
Sanitize data before displaying in markdown editor (#3205)
* Sanitize data before displaying in markdown editor

* Use the sanitize option provided by easymde

* Spelling fix
2022-06-16 10:57:28 +10:00
Oliver
cd418d6948
Merge pull request from GHSA-rm89-9g65-4ffr
* Enable HTML escaping for all tables by default

* Enable HTML escaping for all tables by default

* Adds automatic escaping for bootstrap tables where custom formatter function is specified

- Intercept the row data *before* it is provided to the renderer function
- Adds a function for sanitizing nested data structure

* Sanitize form data before processing
2022-06-15 18:33:33 +10:00
Oliver
76aa3a75f2
Merge pull request from GHSA-fr2w-mp56-g4xp
* Enforce file download for attachments table(s)

* Enforce file download for attachment in 'StockItemTestResult' table
2022-06-15 18:31:56 +10:00
Oliver
090f4f4387
Converting more forms to the API (#3181)
* Delete category via the API

* Delete StockLocation via the API

* Delete StockItem via the API

- Removes the final instance of AjaxDelete

* Remove URL path

* Add missing code
2022-06-11 21:53:26 +10:00
Oliver
258957c14c
SupplierPart availability (#3148)
* Adds new fields to the SupplierPart model:

- available
- availability_updated

* Allow availability_updated field to be blank

* Revert "Remove stat context variables"

This reverts commit 0989c308d0.

* Increment API version

* Adds availability information to the SupplierPart API serializer

- If the 'available' field is updated, the current date is added to the availability_updated field

* Add 'available' field to SupplierPart table

* More JS refactoring

* Add unit testing for specifying availability via the API

* Display availability data on the SupplierPart detail page

* Add ability to set 'available' quantity from the SupplierPart detail page

* Revert "Revert "Remove stat context variables""

This reverts commit 3f98037f79.
2022-06-08 21:49:07 +10:00
Oliver
403655e3d2
Adding bulk deletion endpoint for notifications (#3154)
* Catch DoesNotExist error

* Move notificationtable function to js file

* Fix for custom metadata class

- Previously only worked if a POST or PUT action was available on the endpoint
- So, a ListAPIView endpoint would not actually work!
- Adding in a BulkDelete mixin to a ListAPIView caused failure

* Add unit test to ensure new OPTIONS metadata updates are checked

* Expand functionality of the existing BulkDelete mixin

- Allow deletion by custom filters
- Allow each implementing class to implement custom filters
- Adds more unit testing for BulkDelete mixin class

* Add bulk delete operation for Notification API

- Ensure users can only delete their *own* notifications

* Improve notification tables / buttons / etc

* Adds unit testing for bulk delete of notifications

- Fixed API permissions for notifications list endpoint

* Update BulkDelete operations for the StockItemTestResult table

* Use filters parameter in attachments table to ensure that only correct attachments are deleted

* JS linting

* Fixes for unit tests
2022-06-08 07:45:30 +10:00
Oliver
6b038d85b6
Notification on new orders (#3145)
* Trigger a notification when a new SalesOrder is created

- Notify the "responsible" owners (excluding the creator)
- Add unit test for new notification

* Adds notification when a new PurchaseOrder is created

* Add notification when a new build order is created

- Includes unit tests

* Refactor order notification code

- Adds a "exclude users" option for sending notifications

* Fixes for notification refactoring

* make notification a helper

* reduce statements togehter

* make reuse easier

* Add docs

* Make context variables clearer

* fix assertation

* Fix set notation

Co-authored-by: Matthias <code@mjmair.com>
2022-06-07 08:11:11 +10:00
Oliver
00b75d792e
Adds API mixin for "bulk delete" (#3146)
* Introduces a BulkDelete API mixin class

- Allows deletion of multiple items against a single API request

* Bump API version

* Adds BulkDelete mixin to StockItemTestResult API class

* refactor "multi BOM Item delete" to use new approach

* Refactor various attachment API endpoints

* Refactor multi delete for StockItem

* Convert remaining enndpoints over

* Fix for API test code
2022-06-07 07:25:12 +10:00
Oliver
88a0e38b69
Fix "polarity" of modal form submit button (#3142) 2022-06-06 20:43:50 +10:00
Oliver
1e6bdfbcab
Overdue order notification (#3114)
* Adds a background task to notify users when a PurchaseOrder becomes overdue

* Schedule the overdue purchaseorder check to occur daily

* Allow notifications to be sent to "Owner" instances

- Extract user information from the Owner instance

* add unit test to ensure notifications are sent for overdue purchase orders

* Adds notification for overdue sales orders

* Clean up notification display panel

- Simplify rendering
- Order "newest at top"
- Element alignment tweaks

* style fixes

* More style fixes

* Tweak notification padding

* Fix import order

* Adds task to notify user of overdue build orders

* Adds unit tests for build order notifications

* Refactor subject line for emails:

- Use the configured instance title as a prefix for the subject line

* Add email template for overdue build orders

* Fix unit tests to accommodate new default value

* Logic error fix
2022-06-06 19:12:29 +10:00
Oliver
a066fcc909
Add new global setting to control auto-upload of test reports (#3137)
* Add new global setting to control auto-upload of test reports

* Adds callback to attach a copy of the test report when printing

* Fix for all attachment API endpoints

- The AttachmentMixin must come first!
- User was not being set, as the custom 'perform_create' function was never called

* Remove duplicated UserSerializer

* display uploading user in attachment table

* Add unit test to check the test report is automatically uploaded
2022-06-06 15:20:41 +10:00
Oliver
2b1d8f5b79
Set part category (#3134)
* Refactor function to enable / disable submit button on modal forms

* Category selection now just uses the AP

* Remove unused forms / views

* JS linting fixes

* remove outdated unit test
2022-06-06 13:00:30 +10:00
Oliver
fe8f111a63
Delete part via API (#3135)
* Updates for the PartRelated model

- Deleting a part also deletes the relationships
- Add unique_together requirement
- Bug fixes
- Added unit tests

* Adds JS function to delete a part instance

* Remove legacy delete view

* JS linting
2022-06-06 11:42:22 +10:00
Oliver
bbbfd003e0
Convert category parameter forms to use the API (#3130)
* Moving PartCategoryParameterTemplate model to the API

- Add detail API endpoint
- Add 'create' action to LIST endpoint

* Update settings page to use the new API forms

* Remove old views / forms

* Update API version

* Fix table buttons

* Add title to deletion form

* Add unit tests for new API views
2022-06-06 00:25:08 +10:00
Oliver
2e40f3ccf3
Move PartParameterTemplate model to the API (#3123)
* Adds detail API view for the PartParameterTemplate model

* Use API methods rather than server-side forms

* Remove old views / forms

* Update API version
2022-06-03 17:11:19 +10:00
Oliver
309ed595d7
Queryset annotation refactor (#3117)
* Refactor out 'ordering' serializer annotation field

* Refactor BomItem serializer annotations

* Factor out MPTT OuterRef query

* Add 'available_stock' annotation to SalesOrderLineItem serializer

- Allows for better rendering of stock availability in sales order table

* Improve 'available quantity' rendering of salesorderlineitem table

* Bump API version

* Add docstring
2022-06-02 23:22:47 +10:00
Oliver
66a6915213
Adds 'multi delete' for attachment tables (#3111)
* Adds 'multi delete' for attachment tables

- Should roll out seamlessly to any attachment table

* JS linting
2022-06-01 17:23:36 +10:00
Oliver
02607bd854
Search improvements (#3103)
* Allow part list API to be searched by SKU

* Enable manufacturer parts and supplier parts search preview

* Increment API version

* Remove whitespace

* Remove more whitespace
2022-05-31 11:51:22 +10:00
Matthias Mair
4d8836378b
CI updates (#3087)
* Add pre-commit to the stack

* exclude static

* Add locales to excludes

* fix style errors

* rename pipeline steps

* also wait on precommit

* make template matching simpler

* Use the same code for python setup everywhere

* use step and cache for python setup

* move regular settings up into general envs

* just use full update

* Use invoke instead of static references

* make setup actions more similar

* use python3

* refactor names to be similar

* fix runner version

* fix references

* remove incidential change

* use matrix for os

* Github can't do this right now

* ignore docstyle errors

* Add seperate docstring test

* update flake call

* do not fail on docstring

* refactor setup into workflow

* update reference

* switch to action

* resturcture

* add bash statements

* remove os from cache

* update input checks

* make code cleaner

* fix boolean

* no relative paths

* install wheel by python

* switch to install

* revert back to simple wheel

* refactor import export tests

* move setup keys back to not disturbe tests

* remove docstyle till that is fixed

* update references

* continue on error

* use relativ action references

* Change step / job docstrings
2022-05-28 10:38:12 +10:00
Oliver
6c7a80c141
Check user permissions before performing search (#3083)
* Check user permissions before performing search

* JS linting
2022-05-27 13:26:45 +10:00
Oliver
643df4761d
Enable 'tree view' for build order table (#3070)
* Enable 'tree view' for build order table

* Ensure we pass locale code to the build table

* Adjust button class based on current context

* Fix display of 'child builds' table on build page

* Force a rebuild of the entire table when the filters are refreshed

* Refactor PurchaseOrder table also

* Refactor existing SalesOrder table also

* JS linting
2022-05-26 15:41:53 +10:00
Oliver
2d1776a151
Refactor 'DeleteManufacturerPart' form (#3067)
* Refactor 'DeleteManufacturerPart' form

- Remove duplicated forms
- Update style to match other forms
- Block on each deletion before progressing to the next one

* PEP fix

* Adds deleteSupplierParts function

* Refactor all instances of supplier part deletion

* Refactor tractor : use convenience function for bootstraptable.getSelections

* Add deleter for manufacturerpartparameter.

Refactor existing code into a single function

* Refactor deletion for stock items

* JS linting
2022-05-25 23:35:53 +10:00
Oliver
2378073c61
SalesOrderShipment improvements (#3058)
* Adds two new fields to SalesOrderShipment model:

- Invoice number (char)
- Link (URL)

* Bump API version

* Update API / serializer / JS

- Allow entry of new fields at time of shipping

* PEP fixes

* Actually fix the PEP issues

* Unit testing: check some more fields
2022-05-25 11:00:19 +10:00