feat(base): show warning bar if the user has not set a default organization

!42 fixes #133
This commit is contained in:
2024-07-17 23:51:25 +09:30
parent 416e029c23
commit 60538e1cec
3 changed files with 33 additions and 0 deletions

View File

@ -74,6 +74,23 @@ def user_settings(context) -> int:
return None
def user_default_organization(context) -> int:
""" Provides the users default organization.
Returns:
int: Users Default Organization
"""
if context.user.is_authenticated:
settings = UserSettings.objects.filter(user=context.user)
if settings[0].default_organization:
return settings[0].default_organization.id
return None
def nav_items(context) -> list(dict()):
""" Fetch All Project URLs
@ -203,4 +220,5 @@ def common(context):
'nav_items': nav_items(context),
'social_backends': social_backends(context),
'user_settings': user_settings(context),
'user_default_organization': user_default_organization(context)
}

View File

@ -76,6 +76,15 @@ section h2 span svg {
fill: #177ee6;
}
.warning-bar {
background-color: #f1d599;
border: 1px solid #ecb785;
height: 30px;
line-height: 30px;
width: 100%;
padding: 0px 20px 0px 20px
}
</style>
<section>
@ -100,6 +109,9 @@ section h2 span svg {
{% endblock content_header_icon %}
{% endif %}
</h2>
{% if not user_default_organization %}
<div class="warning-bar">You do not have a <b>default organization</b> set, go to <a href="{% url '_settings_user' pk=user_settings %}">user settings</a> to set one</div>
{% endif %}
{% block article %}
<article id="content-body">
{% block content %}{% endblock %}

View File

@ -69,6 +69,9 @@ This configuration can also be obtained from API endpoint `/api/config/<machine-
### Inventory
!!! tip
Within your "user settings" you must have a default organization set. Without this the inventory will not be added as this is how the inventory logic determines which organization for the device to be created in.
It's possible for a machine to be inventoried and have the report passed to the [inventory endpoint](../api.md#inventory-reports). This report will update the device within the interface and provides the option to use scheduled inventory gathering to keep the device up to date.
The report can contain the following information: