Skip to content

CRUD Material - #383

Closed
Keithy03 wants to merge 3964 commits into
Solvosoft:developmentfrom
Keithy03:UpdateMaterial
Closed

Keithy03 wants to merge 3964 commits into
Solvosoft:developmentfrom
Keithy03:UpdateMaterial

Conversation

@Keithy03

@Keithy03 Keithy03 commented Sep 4, 2024

Copy link
Copy Markdown

Update the Material Management view to use Gentelella's CRUDAL:

Creation of the API where serializers, material management, and filters were created.
Creation of the view and form for the CRUD.

luisza and others added 30 commits January 22, 2024 14:47
luisza and others added 15 commits May 11, 2024 19:31
* Allow user to switch to other organization user

* Update translations

* Update locales and fixed contenttype on fixtures on tests

* Add to admin site the impostor model

* Fixed impostor logout

* Add boostrap classes for close token button text

---------

Co-authored-by: Kejebo <kenjen041@gmail.com>
* Validate if do not exists a previous precursor report in task version

* Remove precursor reports of the actual month


class ValidateMaterialCapacitySerializer(serializers.ModelSerializer):
object = serializers.PrimaryKeyRelatedField(queryset=Object.objects.using(

@marcelagz marcelagz Sep 4, 2024

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to verify the object is a material object type, rewrite the validate function from this serializer and validate the type object == Object.MATERIAL, raise a validationerror and add logger.debug with the info error and return de validate data.

{data: "id", name: "id", title: "ID", type: "string", visible: false},
{data: "code", name: "code", title: "Code", type: "string", visible: true},
{data: "name", name: "name", title: "Name", type: "string", visible: true},
{data: "actions", name: "actions", title: "Actions", type: "string", visible: true},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to include capacity and capacity unit fields in this columns.

Comment thread src/laboratory/views/objects.py Outdated
"created_by": request.user.pk},
modal_id="#create_obj_form",
laboratory_pk=lab_pk),
"update_form": MaterialForm(prefix="update", initial={"laboratory": lab_pk},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the initial parameter in update_form, the instance is already created so is not neccesary to send initial data here.

Comment thread src/laboratory/forms.py Outdated
laboratory_pk = kwargs.pop('laboratory_pk')
super(MaterialForm, self).__init__(*args, **kwargs)
self.fields['object'].required = False
self.fields['is_container'].initial = True

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can be removed self.fields['is_container'].initial = True and you can define this initial from create_from in view_material_list

Comment thread src/laboratory/api/views.py Outdated
response_data = material_serializer.data
material_ca_data = material_ca_serializer.data

# THIS ID SHOULDN'T REPLACE THE MAIN ID(EQUIPMENT OBJECT)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EQUIPMENT OBJECT??

Comment thread src/laboratory/api/views.py Outdated
if errors:
raise ValidationError(errors)

def get_material_ca_serializer(self, instance, request, partial, lab_pk):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete de name function and variables -- > ca --> capacity.

Comment thread src/laboratory/api/views.py Outdated
material_ca_instance = instance.materialcapacity
material_ca_serializer = ValidateMaterialCapacitySerializer(
material_ca_instance, data=data, partial=partial,
context={"lab_pk": lab_pk})

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you are sending lab_pk by context if in this serializer is not using this parameter.

Comment thread src/laboratory/forms.py Outdated

def __init__(self, *args, **kwargs):
modal_id = kwargs.pop('modal_id')
laboratory_pk = kwargs.pop('laboratory_pk')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

laboratory_pk variable is not necessary, just send required data. Also you can copy all fields in MaterialCapacityObjectForm form inside this other form because is a new form just for material crud, the MaterialCapacityObjectForm form will be deleted after this process.

datatable_inits: datatable_inits,
add_filter: true,
relation_render: {'field_autocomplete': 'text' },
delete_display: data => data['code'],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Name is field better here. delete_display: data => data['name'],

@luisza
luisza deleted the branch Solvosoft:development September 16, 2026 16:55
@luisza luisza closed this Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants