Skip to content

Commit

Permalink
Merge pull request #670 from WHOIGit/mario_dev_1.7.0
Browse files Browse the repository at this point in the history
Mario dev 1.7.0
  • Loading branch information
ethanandrews authored Jul 22, 2024
2 parents bfd4c8a + e61195f commit 8b761dc
Show file tree
Hide file tree
Showing 12 changed files with 241 additions and 28 deletions.
2 changes: 2 additions & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
DATA_UPLOAD_MAX_MEMORY_SIZE = None

DEFAULT_AUTO_FIELD='django.db.models.AutoField'

# Celery Settings
if USE_TZ:
# http://docs.celeryproject.org/en/latest/userguide/configuration.html#std:setting-timezone
Expand Down
5 changes: 1 addition & 4 deletions roundabout/admintools/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,7 @@ def clean(self, data, initial=None):


class ImportCalibrationForm(forms.Form):
cal_csv = forms.FileField(
widget=MultipleFileField,
label = 'Generates Calibration data '
)
cal_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down
55 changes: 55 additions & 0 deletions roundabout/assemblies/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,17 @@ def delete(self, request, *args, **kwargs):

return JsonResponse(data)

def form_valid(self, form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.id,
'object_type': self.object.get_object_type(),
}
self.object.delete()

return JsonResponse(data)


### CBV views for AssemblyRevision model ###

Expand Down Expand Up @@ -575,6 +586,17 @@ def delete(self, request, *args, **kwargs):

return JsonResponse(data)

def form_valid(self, form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.id,
'object_type': self.object.get_object_type(),
}
self.object.delete()

return JsonResponse(data)


### CBV views for AssemblyPart model ###

Expand Down Expand Up @@ -786,6 +808,28 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self, form):
self.object = self.get_object()

# Need to check if there's Inventory on this AssemblyPart. If so, need to bump them off the Build
if self.object.inventory.exists():
for item in self.object.inventory.all():
item.detail = 'Removed from %s' % (item.build)
action_record = Action.objects.create(action_type='removefrombuild', detail=item.detail, location=item.location,
user=self.request.user, inventory=item)
item.build = None
item.assembly_part = None
item.parent = None
item.save()

data = {
'message': "Successfully submitted form data.",
'object_type': self.object.get_object_type(),
'parent_id': self.object.parent_id,
}
self.object.delete()
return JsonResponse(data)


# Assembly Types Template Views

Expand Down Expand Up @@ -1081,5 +1125,16 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self, form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.id,
'parent_type': 'comment',
'object_type': self.object.get_object_type(),
}
self.object.delete()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('assemblies:ajax_assemblyparts_detail', args=(self.object.assembly_part.id, ))
12 changes: 12 additions & 0 deletions roundabout/builds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,18 @@ def delete(self, request, *args, **kwargs):

return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.location.id,
'parent_type': 'locations',
'object_type': self.object.get_object_type(),
}
self.object.delete()

return JsonResponse(data)


# Create a new Snapshot copy of a Build
class BuildAjaxSnapshotCreateView(LoginRequiredMixin, AjaxFormMixin, CreateView):
Expand Down
24 changes: 24 additions & 0 deletions roundabout/calibrations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,18 @@ def delete(self, request, *args, **kwargs):
thrsh_job = async_update_cal_thresholds.delay()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.inventory.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
thrsh_job = async_update_cal_thresholds.delay()
return JsonResponse(data)

def get_success_url(self):
return reverse('inventory:ajax_inventory_detail', args=(self.object.inventory.id,))

Expand Down Expand Up @@ -648,6 +660,18 @@ def delete(self, request, *args, **kwargs):
job = check_events.delay()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.part.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
job = check_events.delay()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('parts:ajax_part_detail', args=(self.object.part.id, ))

Expand Down
45 changes: 45 additions & 0 deletions roundabout/configs_constants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,17 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.inventory.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('inventory:ajax_inventory_detail', args=(self.object.inventory.id, ))

Expand Down Expand Up @@ -590,6 +601,18 @@ def delete(self, request, *args, **kwargs):
job = check_events.delay()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.part.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
job = check_events.delay()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('parts:ajax_part_detail', args=(self.object.part.id, ))

Expand Down Expand Up @@ -820,6 +843,17 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.inventory.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('inventory:ajax_inventory_detail', args=(self.object.inventory.id, ))

Expand Down Expand Up @@ -1050,6 +1084,17 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
'message': "Successfully submitted form data.",
'parent_id': self.object.assembly_part.id,
'parent_type': 'part_type',
'object_type': self.object.get_object_type(),
}
self.object.delete()
return JsonResponse(data)

def get_success_url(self):
return reverse_lazy('assemblies:ajax_assemblyparts_detail', args=(self.object.assembly_part.id, ))

12 changes: 12 additions & 0 deletions roundabout/cruises/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,18 @@ def delete(self, request, *args, **kwargs):

return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
"message": "Successfully submitted form data.",
"parent_id": self.object.cruise_start_date.year,
"parent_type": "year_group",
"object_type": self.object.get_object_type(),
}
self.object.delete()

return JsonResponse(data)


# Vessel CBV views
# ----------------------
Expand Down
18 changes: 18 additions & 0 deletions roundabout/inventory/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,15 @@ def delete(self, request, *args, **kwargs):
self.object.delete()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
"message": "Successfully submitted form data.",
"parent_id": self.object.parent_id,
}
self.object.delete()
return JsonResponse(data)


# Base Views

Expand Down Expand Up @@ -2288,3 +2297,12 @@ def delete(self, request, *args, **kwargs):
}
self.object.delete()
return JsonResponse(data)

def form_valid(self,form):
self.object = self.get_object()
data = {
"message": "Successfully submitted form data.",
"parent_id": self.object.location_id,
}
self.object.delete()
return JsonResponse(data)
38 changes: 14 additions & 24 deletions roundabout/ooi_ci_tools/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,14 @@ def validate_import_config_vessels(import_config, reader, filename):
class MultipleFileInput(forms.ClearableFileInput):
allow_multiple_selected = True

def __init__(self, attrs=None):
attrs = attrs or {}
attrs['multiple'] = 'multiple'
super().__init__(attrs)

def value_from_datadict(self, data, files, name):
return files.getlist(name)

class MultipleFileField(forms.FileField):
def __init__(self, *args, **kwargs):
kwargs.setdefault("widget", MultipleFileInput())
Expand All @@ -525,10 +533,7 @@ def clean(self, data, initial=None):

# Handles Deployment CSV file submission and field validation
class ImportDeploymentsForm(forms.Form):
deployments_csv = forms.FileField(
widget=MultipleFileField,
required=False
)
deployments_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down Expand Up @@ -655,10 +660,7 @@ def clean_deployments_csv(self):

# Handles Vessel CSV file submission and field validation
class ImportVesselsForm(forms.Form):
vessels_csv = forms.FileField(
widget=MultipleFileField,
required=False
)
vessels_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down Expand Up @@ -789,10 +791,7 @@ def clean_vessels_csv(self):

# Handles Cruise CSV file submission and field validation
class ImportCruisesForm(forms.Form):
cruises_csv = forms.FileField(
widget=MultipleFileField,
required=False
)
cruises_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down Expand Up @@ -1013,10 +1012,7 @@ def validate_cal_files(csv_files,ext_files):

# Handles Calibration CSV file submission and field validation
class ImportCalibrationForm(forms.Form):
calibration_csv = forms.FileField(
widget=MultipleFileField,
required = False
)
calibration_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down Expand Up @@ -1108,10 +1104,7 @@ def save(self, commit = True):

# Handles Reference Designator CSV file submission and field validation
class ImportReferenceDesignatorForm(forms.Form):
refdes_csv = forms.FileField(
widget=MultipleFileField,
required = False
)
refdes_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down Expand Up @@ -1141,10 +1134,7 @@ def clean_refdes_csv(self):

# Handles Bulk Upload CSV file submission and field validation
class ImportBulkUploadForm(forms.Form):
bulk_csv = forms.FileField(
widget=MultipleFileField,
required = False
)
bulk_csv = MultipleFileField(required=False)
user_draft = forms.ModelMultipleChoiceField(
queryset = User.objects.all().exclude(groups__name__in=['inventory only']).order_by('username'),
required=False,
Expand Down
Loading

0 comments on commit 8b761dc

Please sign in to comment.