Copy references and tolerances between units

Issue #137 resolved
Wenze van Klink created an issue

At the moment the following steps need to be taken to use a new TestList:

  1. Create Tests
  2. Add Tests to TestList
  3. Assign TestList to Unit(s)
  4. Assign references and tolerances to each test

I think there should be a third step available in the admin 'Copy References & Tolerances'.

At the moment the references and tolerances need to be set for each Unit specifically. We have 8 accelerators on which we use TestLists which are exactly the same, with the same References and Tolerances. If a TestList contains 20 tests this would mean setting 160 References and Tolerances, a lot of work.

Therefore I would like to introduce a admin page: 'Copy References & Tolerances'. Then the steps would be:

  1. Assign TestList to Unit(s)
  2. Assign references and tolerances to each test for one unit
  3. Copy References and Tolerances to other Units with same TestList

What is needed:

  • Url in the admin page to 'Copy References & Tolerances'
  • view for copying the references and tolerances
  • some jQuery to make it a little bit interactive
  • Tests

Suggestion:

  • Create a url in the admin page with: django-admin views
  • There a form would display the following: 1. Select Unit to copy from (get TestLists, jQuery), 2. Select TestList to Copy (get Units with same TestList, jQuery), 3. Select Unit to copy too, 4. 'Copy References & Tolerances'

Questions:

  • Is it a good idea to use django-admin views? pros: url in admin, easy setup, cons: url on the bottom of the admin (see image).
  • Can is easily use the django-admin css for my template to keep the same look? Or should I use Bootstrap?
  • Where would be the best place to put the code for saving the References and Tolerances? Models.py?
  • Where would be the best place to create the view(s)? I thought maybe: qa/views/custom_admin.py

Randle I hope you like this idea. Would help us out alot in terms of repetition. Also: I cannot assign this issue to me?

Comments (6)

  1. Randle Taylor

    Yes I agree, this is currently a huge pain! We also have many accelerators where it would be very nice to copy over the references :)

    Your plan looks quite good.

    • Is it a good idea to use django-admin views? pros: url in admin, easy setup, cons: url on the bottom of the admin (see image).

    I'm not too familiar with this package but it looks like it should work. I like keeping this functionality in the admin (rather than the front-end-site) for consistency.

    • Can is easily use the django-admin css for my template to keep the same look? Or should I use Bootstrap?

    Yes I would say use the admin css. I don't think it's too pretty but I think we should be consistent in the look of the admin site. Maybe in the future we can look at Django Admin 2 or Grappelli to make the admin look nicer.

    • Where would be the best place to put the code for saving the References and Tolerances? Models.py?

    Hmmm....I think the easiest might be to put the code on the UnitTestCollection model. So you could create a method on UnitTestCollection like so:

    class UnitTestCollection(models.Model):
        ...
        def copy_references(self, source_unit):
    
            all_tests = self.tests_object.all_tests()
            source_unit_test_infos = UnitTestInfo.objects.filter(test__in=all_tests, unit=source_unit)
    
            for source_uti in source_unit_test_infos:
                dest_uti = UnitTestInfo.objects.get(test=uti.test, unit=self.unit)
                dest_uti.reference = source_uti.reference
                dest_uti.tolerance = source_uti.tolerance
                dest_uti.save()
    

    or something along those lines.

    • Where would be the best place to create the view(s)? I thought maybe: qa/views/custom_admin.py

    That's where I would put it. custom_admin.py is fine but I might just call it admin.py (e.g. qa/views/admin.py). I don't have a strong preference either way though :)

  2. Log in to comment