Skip to content
Open
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
4 changes: 2 additions & 2 deletions cnr-ifn.mi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This repository contains the software developed during the internship at CNR-IFN

- **LabLogbook**: Integrated within the existing UdyniManagement Django project, LabLogbook is a web-based application designed for efficient experiment and sample management, coupled with a comprehensive digital logbook. Furthermore, it exposes RESTful APIs, laying the groundwork for the future development of a robust FAIR (Findable, Accessible, Interoperable, Reusable) data infrastructure within the UDynI laboratories.

**Important Note**: LabLogbook is not a standalone application. To run it, is necessary to set up the UdyniManagement project first by following the instructions provided below.
**Important Note**: LabLogbook is not a standalone application. To run it, it is necessary to set up the UdyniManagement project first by following the instructions provided below.


## UdyniManagement Setup
Expand Down Expand Up @@ -46,7 +46,7 @@ sudo apt install libsasl2-dev

### Django Project Configuration

1. **Apply Migrations:** These commands ensure your database schema is up-to-date with the project's models.
1. **Apply Migrations:** These commands ensure your database schema is up to date with the project's models.

```bash
python3 manage.py makemigrations
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/AccountManagement/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings

from AccountManagement.models import RegistrationRequest # import the settings file
from .ldap import UdyniLdap
from AccountManagement.ldap import UdyniLdap

UserModel = get_user_model()

Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/AccountManagement/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path, reverse_lazy
from django.views.generic.base import RedirectView

from . import views
from AccountManagement import views


urlpatterns = [
Expand Down
6 changes: 3 additions & 3 deletions cnr-ifn.mi/UdyniManagement/AccountManagement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

from UdyniManagement.menu import UdyniMenu
from UdyniManagement.views import ListViewMenu, CreateViewMenu, TemplateViewMenu, UpdateViewMenu, DeleteViewMenu, FormViewMenu, udyni_error_view
from .ldap import UdyniLdap
from .forms import SetPasswordForm, PasswordChangeForm, PasswordResetForm, RegistrationForm, AccountCreationForm, AccountRejectionForm, UserDeleteForm, EditProfileForm
from .models import RegistrationRequest
from AccountManagement.ldap import UdyniLdap
from AccountManagement.forms import SetPasswordForm, PasswordChangeForm, PasswordResetForm, RegistrationForm, AccountCreationForm, AccountRejectionForm, UserDeleteForm, EditProfileForm
from AccountManagement.models import RegistrationRequest


# =======================
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Accounting/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from .models import GAE
from Accounting.models import GAE


class GaeForm(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Accounting/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path, reverse_lazy
from django.views.generic.base import RedirectView

from . import views
from Accounting import views

urlpatterns = [
# Gestione GAE
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Accounting/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import datetime
from collections import OrderedDict
from django.db.models import Q, F, Sum
from .models import SplitBudget, SplitVariazione, SplitImpegno
from Accounting.models import SplitBudget, SplitVariazione, SplitImpegno

def create_split_accounting_detail(contab):
# First we get the budget
Expand Down
8 changes: 4 additions & 4 deletions cnr-ifn.mi/UdyniManagement/Accounting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
from UdyniManagement.menu import UdyniMenu
from UdyniManagement.views import ListViewMenu, CreateViewMenu, TemplateViewMenu, UpdateViewMenu, DeleteViewMenu

from .models import VoceSpesa, GAE, Stanziamento, Variazione, Impegno, Mandato
from .models import SplitContab, SplitBudget, SplitImpegno, SplitVariazione
from .forms import GaeForm
from .utils import create_split_accounting_detail
from Accounting.models import VoceSpesa, GAE, Stanziamento, Variazione, Impegno, Mandato
from Accounting.models import SplitContab, SplitBudget, SplitImpegno, SplitVariazione
from Accounting.forms import GaeForm
from Accounting.utils import create_split_accounting_detail


# =============================
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/LabLogbook/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from .models import Comment, CommentContent
from LabLogbook.models import Comment, CommentContent

class CommentForm(forms.ModelForm):
class Meta:
Expand Down
1 change: 0 additions & 1 deletion cnr-ifn.mi/UdyniManagement/LabLogbook/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.db import models
from mptt.models import MPTTModel, TreeForeignKey # used for Comments
from django.contrib.auth import get_user_model
from django.core.exceptions import ValidationError


UserModel = get_user_model()
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/LabLogbook/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.urls import reverse
from django.utils.timezone import now, timedelta
from django.contrib.auth import get_user_model
from .models import Laboratory, ExperimentalStation, Sample, Experiment, SampleForExperiment
from LabLogbook.models import Laboratory, ExperimentalStation, Sample, Experiment, SampleForExperiment
import json

UserModel = get_user_model()
Expand Down
4 changes: 2 additions & 2 deletions cnr-ifn.mi/UdyniManagement/LabLogbook/urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from . import views
from . import views_api
from LabLogbook import views
from LabLogbook import views_api
from UdyniManagement.views import EmptyView

from django.urls import path, reverse_lazy
Expand Down
5 changes: 2 additions & 3 deletions cnr-ifn.mi/UdyniManagement/LabLogbook/views.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
from .models import Laboratory, Sample, ExperimentalStation, Experiment, SampleForExperiment, Measurement, File, Comment, CommentContent
from .forms import CommentForm, CommentContentForm
from LabLogbook.models import Laboratory, Sample, ExperimentalStation, Experiment, SampleForExperiment, Measurement, File, Comment, CommentContent
from LabLogbook.forms import CommentForm, CommentContentForm
from UdyniManagement.views import ListViewMenu, CreateViewMenu, UpdateViewMenu, DeleteViewMenu
from UdyniManagement.menu import UdyniMenu

from django.contrib.auth.mixins import PermissionRequiredMixin
from django.views import View
from django.db.models import Prefetch
from django.shortcuts import get_object_or_404, render, redirect
from django.urls import reverse_lazy

Expand Down
8 changes: 4 additions & 4 deletions cnr-ifn.mi/UdyniManagement/LabLogbook/views_api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from .models import ExperimentalStation
from .models import Experiment
from .models import SampleForExperiment
from .models import Measurement, Sample, File, Comment, CommentContent
from LabLogbook.models import ExperimentalStation
from LabLogbook.models import Experiment
from LabLogbook.models import SampleForExperiment
from LabLogbook.models import Measurement, Sample, File, Comment, CommentContent

import json
from django.views import View
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Projects/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django import forms
from .models import ResearcherRole, Project
from Projects.models import ResearcherRole, Project


class ResearcherRoleForm(forms.ModelForm):
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Projects/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path, reverse_lazy
from django.views.generic.base import RedirectView

from . import views
from Projects import views

urlpatterns = [
path('', RedirectView.as_view(url=reverse_lazy('project_view'), permanent=False), name='projects_index'),
Expand Down
4 changes: 2 additions & 2 deletions cnr-ifn.mi/UdyniManagement/Projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from django.urls import reverse_lazy
from django.db.models import F, Subquery

from .models import Researcher, ResearcherRole, Project, WorkPackage, ConflictOfInterest
from Projects.models import Researcher, ResearcherRole, Project, WorkPackage, ConflictOfInterest

from django.contrib.auth.mixins import PermissionRequiredMixin

from .forms import ResearcherRoleForm, ProjectForm
from Projects.forms import ResearcherRoleForm, ProjectForm

from django.views import View
from UdyniManagement.views import ListViewMenu, CreateViewMenu, UpdateViewMenu, DeleteViewMenu
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Reporting/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib import admin
from .models import BankHoliday, EpasCode, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedMission, ReportedWorkWorkpackage, TimesheetHours
from Reporting.models import BankHoliday, EpasCode, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedMission, ReportedWorkWorkpackage, TimesheetHours

# Register your models here.
admin.site.register(BankHoliday)
Expand Down
6 changes: 3 additions & 3 deletions cnr-ifn.mi/UdyniManagement/Reporting/timesheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from django.db.models import Q, F, Sum, Value, Subquery, OuterRef
from django.db.models.functions import ExtractYear, ExtractMonth, Coalesce
from .models import EpasCode, PresenceData, ReportedWork, ReportedMission, TimesheetHours
from .utils import check_bank_holiday, get_workpackages_fractions
from .utils import ReportingError
from Reporting.models import EpasCode, PresenceData, ReportedWork, ReportedMission, TimesheetHours
from Reporting.utils import check_bank_holiday, get_workpackages_fractions
from Reporting.utils import ReportingError
from Tags.templatetags import tr_month


Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/Reporting/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from django.db.models import Q
from Tags.templatetags.tr_month import month_num2it

from .models import BankHoliday
from Reporting.models import BankHoliday


def process_presences(xls, researcher):
Expand Down
16 changes: 8 additions & 8 deletions cnr-ifn.mi/UdyniManagement/Reporting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
from django.db.models.functions import ExtractYear, ExtractMonth, Concat, Coalesce, Floor, Least

from Projects.models import Project, Researcher, ResearcherRole, WorkPackage, ConflictOfInterest
from .models import EpasCode, BankHoliday, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedWorkWorkpackage, ReportedMission, TimesheetHours
from Reporting.models import EpasCode, BankHoliday, PersonnelCost, PresenceData, ReportingPeriod, ReportedWork, ReportedWorkWorkpackage, ReportedMission, TimesheetHours

from .forms import AddReportedMissionForm, EpasCodeUpdateForm, PresenceInputForm, ReportedWorkForm #, ReportingAddForm
from Reporting.forms import AddReportedMissionForm, EpasCodeUpdateForm, PresenceInputForm, ReportedWorkForm #, ReportingAddForm

from .utils import process_presences, summarize_presences, serialize_presences
from .utils import unserialize_presences, check_presences_unique, check_bank_holiday
from .utils import get_workpackages_fractions
from .utils import ReportingError
from .timesheets import CheckTimesheetData, GetTimesheetData
from .print import PrintPFDTimesheet
from Reporting.utils import process_presences, summarize_presences, serialize_presences
from Reporting.utils import unserialize_presences, check_presences_unique, check_bank_holiday
from Reporting.utils import get_workpackages_fractions
from Reporting.utils import ReportingError
from Reporting.timesheets import CheckTimesheetData, GetTimesheetData
from Reporting.print import PrintPFDTimesheet

from Tags.templatetags import tr_month

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Development settings
# NOTE: when running Django rename to development.py and set the environment variable DJANGO_SETTINGS_MODULE=UdyniManagement.settings.development

from . import * # Import base settings from settings/__init__.py
from .development_logging import LOGGING # Import logging configuration for production
from UdyniManagement.settings import * # Import base settings from settings/__init__.py
from UdyniManagement.settings.development_logging import LOGGING # Import logging configuration for production

# Secret key
SECRET_KEY = 'django-insecure-#m^ta)8wnr+v=@o*t5#n&coip**2brq!!j@b8i8-=_+j$3zo9='
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Production settings
# NOTE: when running Django rename to production.py and set the environment variable DJANGO_SETTINGS_MODULE=UdyniManagement.settings.production

from . import * # Import base settings from settings/__init__.py
from production_logging import LOGGING # Import logging configuration for production
from UdyniManagement.settings import * # Import base settings from settings/__init__.py
from UdyniManagement.settings.production_logging import LOGGING # Import logging configuration for production

# Secret key
SECRET_KEY = '*****************' # Set this to a secure random value
Expand Down
4 changes: 2 additions & 2 deletions cnr-ifn.mi/UdyniManagement/UdyniManagement/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""
from django.contrib import admin
from django.urls import include, path
from . import views
from .menu import menu_include
from UdyniManagement import views
from UdyniManagement.menu import menu_include


urlpatterns = [
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/UdyniManagement/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from django.views.generic.edit import CreateView, UpdateView, DeleteView, FormView
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin

from .menu import UdyniMenu
from UdyniManagement.menu import UdyniMenu


# =============================================
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/sigla/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.urls import path, reverse_lazy

from . import views
from sigla import views


urlpatterns = [
Expand Down
2 changes: 1 addition & 1 deletion cnr-ifn.mi/UdyniManagement/sigla/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from UdyniManagement.menu import UdyniMenu

from .sigla import SIGLA
from sigla.sigla import SIGLA

from Accounting.models import GAE

Expand Down
18 changes: 9 additions & 9 deletions cnr-ifn.mi/udyninexus/udyninexus/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .classes.NexusContainer import NexusContainer
from .classes.Beam import Beam
from .classes.Detector import Detector
from .classes.Source import Source
from .classes.Sample import Sample
from .classes.Data import Axis, Data
from .write_nexus import write_nexus
from .exceptions import NexusSaveError, NexusValidationError
from .logging_settings import set_log_level, set_log_file
from udyninexus.classes.NexusContainer import NexusContainer
from udyninexus.classes.Beam import Beam
from udyninexus.classes.Detector import Detector
from udyninexus.classes.Source import Source
from udyninexus.classes.Sample import Sample
from udyninexus.classes.Data import Axis, Data
from udyninexus.write_nexus import write_nexus
from udyninexus.exceptions import NexusSaveError, NexusValidationError
from udyninexus.logging_settings import set_log_level, set_log_file
19 changes: 16 additions & 3 deletions cnr-ifn.mi/udyninexus/udyninexus/classes/Beam.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
from .Instrument import Instrument
from ..utils import create_property_check_type, create_property_check_in_valid_values
from .Source import Source
from udyninexus.classes.Instrument import Instrument
from udyninexus.classes.Source import Source
from udyninexus.utils import create_property_check_type, create_property_check_in_valid_values

from typing import Literal


class Beam(Instrument):
"""
Represents the characteristics of a beam used in spectroscopy experiments.

Attributes:
name_in_nexus (str): Identifier used in the NeXus file. The beam will be saved inside the 'instrument' group under the name 'beam\_\<name_in_nexus\>'.
beam_type (str): Specify the role of the beam ('pump' or 'probe').
parameter_reliability (str): Indicates how the beam characteristics were obtained ('measured', 'nominal').
incident_wavelength (int): Wavelength of the incident beam.
incident_wavelength_units (str): Units of the incident wavelength ('nm', 'um').
incident_polarization (int): Polarization value of the incident beam.
beam_polarization_type (str): Type of beam polarization ('linear', 'circular', 'elliptically', 'unpolarized').
associated_source (Source): Device that emitted the beam. In the NeXus file the path to the source will be specified in the 'associated_source' NXfield.
"""
def __init__(self,
name_in_nexus: str = None,
beam_type: Literal['pump', 'probe'] = None,
Expand Down
27 changes: 25 additions & 2 deletions cnr-ifn.mi/udyninexus/udyninexus/classes/Data.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
from ..utils import create_property_check_one_dimensional_axis_data, create_property_check_isinstance, create_property_check_type, create_property_check_type_for_lists
from .Instrument import Instrument
from udyninexus.classes.Instrument import Instrument
from udyninexus.utils import create_property_check_one_dimensional_axis_data, create_property_check_isinstance, create_property_check_type, create_property_check_type_for_lists

from typing import Optional, List, Any


class Axis:
"""
Represents a one-dimensional axis in data.

Attributes:
name (str): Name used to identify this axis in the NeXus file. This will be the key under which the signal data is stored.
data (List): A one-dimensional sequence of values representing the axis (e.g., range(10)).
units (str): The unit of measurement for the axis values (e.g., 'nm', 'ms'). Defaults to 'index' if not specified.
related_instrument (Instrument): Reference to the instrument that controls or is associated with this axis.\
If specified the signal data will be stored inside this instrument's group in the NeXus file and linked via an NXlink in the 'data' group.\
Otherwise the data of the axis will be directly saved inside the 'data' group.
"""
def __init__(self,
name: str = None,
data: Optional[List] = None,
Expand All @@ -23,6 +35,17 @@ def __init__(self,


class Data:
"""
Represents measured signal data.

Attributes:
signal_name (str): Name used to identify the signal in the NeXus file. This will be the key under which the signal data is stored.
signal_data: A multi-dimensional array of values representing the signal measurements.
signal_units (str): Unit of measurement for the signal values (e.g., 'nm', 'ms').
signal_related_instrument (Instrument): Reference to the instrument that measured the signal. The signal data will be stored inside this instrument's group in the NeXus file and linked via an NXlink in the 'data' group.
axes (List[Axis]): List of axes associated with the signal data.
"""

def __init__(self,
signal_name: str = None,
signal_data: Any = None, # it must be a data with a shape (multi dimensional array)
Expand Down
Loading