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

4.2.1.dev #120

Merged
merged 8 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 20 additions & 0 deletions NEMO/migrations/0041_version_4_2_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.14 on 2022-09-06 16:26

from django.db import migrations, models

import NEMO.utilities


class Migration(migrations.Migration):

dependencies = [
('NEMO', '0040_version_4_2_0'),
]

operations = [
migrations.AlterField(
model_name='chemical',
name='document',
field=models.FileField(blank=True, max_length=500, null=True, upload_to=NEMO.utilities.get_chemical_document_filename),
),
]
2 changes: 1 addition & 1 deletion NEMO/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2398,7 +2398,7 @@ def __str__(self):
class Chemical(models.Model):
name = models.CharField(max_length=200)
hazards = models.ManyToManyField(ChemicalHazard, blank=True, help_text="Select the hazards for this chemical.")
document = models.FileField(null=True, blank=True, upload_to=get_chemical_document_filename)
document = models.FileField(null=True, blank=True, upload_to=get_chemical_document_filename, max_length=500)
url = models.CharField(null=True, blank=True, max_length=200, verbose_name='URL')
keywords = models.TextField(null=True, blank=True)

Expand Down
15 changes: 9 additions & 6 deletions NEMO/rates.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
class Rates(ABC):

rates = None
expand_rates_table = False

@abstractmethod
def load_rates(self):
from NEMO.views.customization import RatesCustomization
self.expand_rates_table = RatesCustomization.get("rates_expand_table", raise_exception=False) == 'enabled'
def load_rates(self, force_reload=False):
pass

def get_consumable_rates(self, consumables: List[Consumable]) -> Dict[str, str]:
if self.rates:
Expand All @@ -36,6 +34,11 @@ def get_tool_rates(self, tools: List[Tool]) -> Dict[str, str]:
def get_tool_rate(self, tool: Tool) -> str:
pass

@staticmethod
def get_expand_rates_table() -> bool:
from NEMO.views.customization import RatesCustomization
return RatesCustomization.get("rates_expand_table", raise_exception=False) == 'enabled'


class NISTRates(Rates):

Expand Down Expand Up @@ -82,8 +85,8 @@ def get_tool_rate(self, tool: Tool) -> str:
return ""
training_rate = self._get_rate_by_table_id_and_class(tool, self.tool_training_rate_class, self.full_cost_rate_class)
training_group_rate = self._get_rate_by_table_id_and_class(tool, self.tool_training_group_rate_class, self.full_cost_rate_class)
html_rate = f'<div class="media"><a onclick="toggle_details(this)" class="pointer collapsed" data-toggle="collapse" data-target="#rates_details"><span class="glyphicon glyphicon-list-alt pull-left notification-icon primary-highlight"></span><span class="glyphicon pull-left chevron glyphicon-chevron-{"right" if not self.expand_rates_table else "down"}"></span></a>'
html_rate += f'<div class="media-body"><span class="media-heading">Rates</span><div id="rates_details" class="collapse {"in" if self.expand_rates_table else ""}"><table class="table table-bordered table-hover thead-light" style="width: auto !important; min-width: 30%; margin-bottom: 0">'
html_rate = f'<div class="media"><a onclick="toggle_details(this)" class="pointer collapsed" data-toggle="collapse" data-target="#rates_details"><span class="glyphicon glyphicon-list-alt pull-left notification-icon primary-highlight"></span><span class="glyphicon pull-left chevron glyphicon-chevron-{"down" if self.get_expand_rates_table() else "right"}"></span></a>'
html_rate += f'<div class="media-body"><span class="media-heading">Rates</span><div id="rates_details" class="collapse {"in" if self.get_expand_rates_table() else ""}"><table class="table table-bordered table-hover thead-light" style="width: auto !important; min-width: 30%; margin-bottom: 0">'

table_header = '<tr style="font-size: large">'
table_header_2 = '<tr style="font-size: x-small">'
Expand Down
2 changes: 1 addition & 1 deletion NEMO/static/fullcalendar/fullcalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9750,7 +9750,7 @@ function Calendar_constructor(element, overrides) {


function refetchEvents() { // can be called as an API method
destroyEvents(); // so that events are cleared before user starts waiting for AJAX
// destroyEvents(); // <-- Commented out. Previous versions of FullCalendar did not have this line. It causes the calendar to visually "flash" every time events are refreshed.
fetchAndRenderEvents();
}

Expand Down
759 changes: 750 additions & 9 deletions NEMO/static/fullcalendar/fullcalendar.min.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions NEMO/static/nemo.css
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ Twitter Typeahead autocomplete dropdown menu isn't chopped off. */
margin-top: 5px;
}

.tool-rates .media-heading
{
display: block;
font-size: medium;
font-weight: 500;
}

.tool-counters
{
margin-top: 5px;
Expand Down
4 changes: 2 additions & 2 deletions NEMO/views/consumables.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
@require_http_methods(['GET', 'POST'])
def consumables(request):
if request.method == "GET":
from NEMO import rates
rate_dict = rates.rate_class.get_consumable_rates(Consumable.objects.all())
from NEMO.rates import rate_class
rate_dict = rate_class.get_consumable_rates(Consumable.objects.all())

dictionary = {
'users': User.objects.filter(is_active=True),
Expand Down
4 changes: 2 additions & 2 deletions NEMO/views/tool_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ def tool_control(request, item_type="tool", tool_id=None):
@require_GET
def tool_status(request, tool_id):
""" Gets the current status of the tool (that is, whether it is currently in use or not). """
from NEMO import rates
from NEMO.rates import rate_class
tool = get_object_or_404(Tool, id=tool_id, visible=True)

dictionary = {
"tool": tool,
"tool_rate": rates.rate_class.get_tool_rate(tool),
"tool_rate": rate_class.get_tool_rate(tool),
"task_categories": TaskCategory.objects.filter(stage=TaskCategory.Stage.INITIAL_ASSESSMENT),
"rendered_configuration_html": tool.configuration_widget(request.user),
"mobile": request.device == "mobile",
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='NEMO',
version='4.2.0',
version='4.2.1',
python_requires='>=3.7',
packages=find_packages(exclude=['NEMO.tests','NEMO.tests.*']),
include_package_data=True,
Expand Down