2019-07-12 20:36:18 -06:00
|
|
|
"""SatNOGS DB django base Forms class"""
|
2021-07-26 13:18:55 -06:00
|
|
|
from bootstrap_modal_forms.forms import BSModalForm, BSModalModelForm
|
2019-04-04 21:46:30 -06:00
|
|
|
from django.core.exceptions import ValidationError
|
2021-07-26 13:18:55 -06:00
|
|
|
from django.forms import ModelChoiceField, TextInput
|
2021-05-22 07:54:20 -06:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2015-04-25 10:47:22 -06:00
|
|
|
|
2021-07-26 13:18:55 -06:00
|
|
|
from db.base.models import Satellite, SatelliteEntry, Transmitter, TransmitterEntry
|
2015-04-25 10:47:22 -06:00
|
|
|
|
|
|
|
|
2019-07-16 07:41:52 -06:00
|
|
|
def existing_uuid(value):
|
|
|
|
"""ensures the UUID is existing and valid"""
|
|
|
|
try:
|
|
|
|
Transmitter.objects.get(uuid=value)
|
2021-01-14 06:14:34 -07:00
|
|
|
except Transmitter.DoesNotExist as error:
|
2019-07-16 07:41:52 -06:00
|
|
|
raise ValidationError(
|
|
|
|
_('%(value)s is not a valid uuid'),
|
|
|
|
code='invalid',
|
|
|
|
params={'value': value},
|
2021-01-14 06:14:34 -07:00
|
|
|
) from error
|
2019-07-16 07:41:52 -06:00
|
|
|
|
|
|
|
|
2021-04-26 03:20:33 -06:00
|
|
|
class TransmitterCreateForm(BSModalModelForm): # pylint: disable=too-many-ancestors
|
2019-07-12 20:36:18 -06:00
|
|
|
"""Model Form class for TransmitterEntry objects"""
|
2015-04-25 10:47:22 -06:00
|
|
|
class Meta:
|
2019-04-04 21:46:30 -06:00
|
|
|
model = TransmitterEntry
|
2019-07-13 19:05:38 -06:00
|
|
|
fields = [
|
2020-08-01 16:50:17 -06:00
|
|
|
'description', 'type', 'status', 'uplink_low', 'uplink_high', 'uplink_drift',
|
2021-01-14 05:50:22 -07:00
|
|
|
'uplink_mode', 'downlink_low', 'downlink_high', 'downlink_drift', 'downlink_mode',
|
|
|
|
'invert', 'baud', 'citation', 'service', 'coordination', 'coordination_url'
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
]
|
2020-08-01 16:50:17 -06:00
|
|
|
labels = {
|
2020-08-01 20:12:13 -06:00
|
|
|
'downlink_low': _('Downlink freq.'),
|
|
|
|
'uplink_low': _('Uplink freq.'),
|
2020-08-01 16:50:17 -06:00
|
|
|
'invert': _('Inverted Transponder?'),
|
|
|
|
}
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
widgets = {
|
|
|
|
'description': TextInput(),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class TransmitterUpdateForm(BSModalModelForm): # pylint: disable=too-many-ancestors
|
|
|
|
"""Model Form class for TransmitterEntry objects"""
|
|
|
|
class Meta:
|
|
|
|
model = TransmitterEntry
|
|
|
|
fields = [
|
2020-08-01 16:50:17 -06:00
|
|
|
'description', 'type', 'status', 'uplink_low', 'uplink_high', 'uplink_drift',
|
2021-01-14 05:50:22 -07:00
|
|
|
'uplink_mode', 'downlink_low', 'downlink_high', 'downlink_drift', 'downlink_mode',
|
2021-03-10 13:54:44 -07:00
|
|
|
'invert', 'baud', 'citation', 'service', 'coordination', 'coordination_url'
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
]
|
2020-08-01 16:50:17 -06:00
|
|
|
labels = {
|
2020-08-01 20:12:13 -06:00
|
|
|
'downlink_low': _('Downlink freq.'),
|
|
|
|
'uplink_low': _('Uplink freq.'),
|
2020-08-01 16:50:17 -06:00
|
|
|
'invert': _('Inverted Transponder?'),
|
|
|
|
}
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
widgets = {
|
|
|
|
'description': TextInput(),
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-16 12:52:30 -06:00
|
|
|
class SatelliteCreateForm(BSModalModelForm): # pylint: disable=too-many-ancestors
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
"""Form that uses django-bootstrap-modal-forms for satellite editing"""
|
|
|
|
class Meta:
|
2021-03-17 00:51:35 -06:00
|
|
|
model = SatelliteEntry
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
fields = [
|
2021-04-26 03:20:33 -06:00
|
|
|
'norad_cat_id', 'norad_follow_id', 'name', 'names', 'description', 'operator',
|
|
|
|
'status', 'countries', 'website', 'dashboard_url', 'launched', 'deployed', 'decayed',
|
|
|
|
'image', 'citation'
|
2019-07-13 19:05:38 -06:00
|
|
|
]
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
labels = {
|
|
|
|
'norad_cat_id': _('Norad ID'),
|
2021-04-26 03:20:33 -06:00
|
|
|
'norad_follow_id': _('Followed Norad ID'),
|
New SatNOGS DB user interface
Initial commit of new UI. There is still some work to be done before this goes into dev, but here is the work so far:
* Updated dependencies to latest 2.x django
* Updated to Bootstrap 4
* New home screen to display most recent satellite entries, most recent data, and contributors
* Adopted django-bootstrap-modal-forms for handling satellite and transmitter creation and update, with more of an emphasis on django's model/view/form model - and a dynamic flow where the modals and details are only loaded when the proper icon is clicked, reducing the overall page size
* Adopted AdminLTE 3.x framework atop Bootstrap 4
* Created reusable cards for satellite and transmitters
* Cards and Modals are organized into subdirectories for template includes and base templates, respectively
* New stats display widgets using BS4 and AdminLTE 3
* Satellite search is redesigned and now accessible from any page of the site
* Introduced datatables for an "All Satellites" view and a modification of the new "All Transmitters" view
* Focus on all UI scaling down to mobile devices
* New model created for Operator (/ Owner): name, names, description, website
* Added django-countries for support of CountryField
* Satellite model expanded to include: Operator, (satellite) website, countries, launched datetime, deployed datetime
* Transmitter suggestions can now be approved in the UI by superusers
* Satellite entries can now be edited in the UI by users with the change satellite permission
* Satellite page is now broken into 'tabbed' panels (Profile, Map, Transmitters, etc) - with the tab menu options appearing in the sidebar or at the top depending on screen size
* Other cleanup and changes that I'm missing for sure.
Signed-off-by: Corey Shields <cshields@gmail.com>
2020-07-25 16:08:44 -06:00
|
|
|
'names': _('Other names'),
|
|
|
|
'countries': _('Countries of Origin'),
|
|
|
|
'launched': _('Launch Date'),
|
|
|
|
'deployed': _('Deploy Date'),
|
|
|
|
'decayed': _('Re-entry Date'),
|
|
|
|
'description': _('Description'),
|
|
|
|
'dashboard_url': _('Dashboard URL'),
|
|
|
|
'operator': _('Owner/Operator'),
|
|
|
|
}
|
2021-04-26 03:20:33 -06:00
|
|
|
widgets = {'names': TextInput()}
|
|
|
|
|
|
|
|
|
2022-04-16 12:52:30 -06:00
|
|
|
class SatelliteUpdateForm(BSModalModelForm): # pylint: disable=too-many-ancestors
|
2021-04-26 03:20:33 -06:00
|
|
|
"""Form that uses django-bootstrap-modal-forms for satellite editing"""
|
|
|
|
class Meta:
|
|
|
|
model = SatelliteEntry
|
|
|
|
fields = [
|
|
|
|
'norad_cat_id', 'norad_follow_id', 'name', 'names', 'description', 'operator',
|
|
|
|
'status', 'countries', 'website', 'dashboard_url', 'launched', 'deployed', 'decayed',
|
|
|
|
'image', 'citation'
|
|
|
|
]
|
|
|
|
labels = {
|
|
|
|
'norad_cat_id': _('Norad ID'),
|
|
|
|
'norad_follow_id': _('Followed Norad ID'),
|
|
|
|
'names': _('Other names'),
|
|
|
|
'countries': _('Countries of Origin'),
|
|
|
|
'launched': _('Launch Date'),
|
|
|
|
'deployed': _('Deploy Date'),
|
|
|
|
'decayed': _('Re-entry Date'),
|
|
|
|
'description': _('Description'),
|
|
|
|
'dashboard_url': _('Dashboard URL'),
|
|
|
|
'operator': _('Owner/Operator'),
|
|
|
|
}
|
|
|
|
widgets = {'names': TextInput()}
|
2021-07-26 13:18:55 -06:00
|
|
|
|
|
|
|
|
|
|
|
class MergeSatellitesForm(BSModalForm):
|
|
|
|
"""Form that uses django-bootstrap-modal-forms for merging satellites"""
|
|
|
|
primary_satellite = ModelChoiceField(
|
|
|
|
label=_('Primary Satellite'),
|
|
|
|
queryset=Satellite.objects.filter(
|
|
|
|
associated_satellite__isnull=True, satellite_entry__approved=True
|
|
|
|
),
|
|
|
|
empty_label="Select the Primary Satellite"
|
|
|
|
)
|
|
|
|
associated_satellite = ModelChoiceField(
|
|
|
|
label=_('Associated Satellite'),
|
|
|
|
queryset=Satellite.objects.filter(
|
|
|
|
associated_satellite__isnull=True, satellite_entry__approved=True
|
|
|
|
),
|
|
|
|
empty_label="Select the Associated Satellite"
|
|
|
|
)
|
|
|
|
|
|
|
|
def clean(self):
|
|
|
|
if any(self.errors):
|
|
|
|
# If there are errors in forms validation no need for validating the formset
|
|
|
|
return
|
|
|
|
|
|
|
|
cleaned_data = super().clean()
|
|
|
|
primary_satellite = cleaned_data.get("primary_satellite")
|
|
|
|
associated_satellite = cleaned_data.get("associated_satellite")
|
|
|
|
|
|
|
|
if primary_satellite == associated_satellite:
|
|
|
|
self.add_error(
|
|
|
|
'associated_satellite',
|
|
|
|
ValidationError(
|
|
|
|
_('Associated Satellite can not be the same with the Primary Satellite'),
|
|
|
|
code='invalid'
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
fields = ['primary_satellite', 'associated_satellite']
|