ODM2 / CZ-Manager

CZ Manager (formerly ODM2 Admin) is an application for site level data management of environmental observations using Observation Data Model 2 (ODM2) for documentation and a detailed walkthrough see:
http://odm2.github.io/CZ-Manager
MIT License
9 stars 12 forks source link

Bug when updating Django-ajax-selects from 1.4.3 to version 1.5.2 #104

Open miguelcleon opened 7 years ago

miguelcleon commented 7 years ago

@lsetiawan I found one of potentially two problems from the Conda packaging @ocefpaf has been working on. The problem appears to be related to the read only group. The bug only appears after upgrading Django-ajax-selects to version 1.5.2 (the servers are using 1.4.3).

NoReverseMatch at /admin/odm2admin/variables/1/change/
Reverse for 'odm2admin_cvvariabletype_add' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

\odm2admin\readonlyadmin.py in get_form
13.        form = super(ReadOnlyAdmin, self).get_form(request, obj, **kwargs)

Can you try to reproduce this?

lsetiawan commented 7 years ago

@miguelcleon This was the similar problem that I encountered on this issue https://github.com/miguelcleon/ODM2-Admin/issues/98 When i comment out the parts of the code that creates the ajax fields it works fine. I will try to look into this further. Maybe Djano-ajax-selects have really updated their syntax. Thanks.

ocefpaf commented 7 years ago

@miguelcleon I agree that fixing it is the best course of action, but let me know if you want me to add an old version (1.4.3) to the channel while we figure this out.

miguelcleon commented 7 years ago

@lsetiawan yes, #98 does appear to be the same problem, just on a different ajax select field.

miguelcleon commented 7 years ago

@ocefpaf yes it would be good to have the old version for the moment. Then I can check if the other problem with the inline forms is still occuring. It doesn't seem to happen on my local development machine.

miguelcleon commented 7 years ago

@lsetiawan so for some reason not all of the ajax select fields have the problem, for instance I can load the results change form fine (/odm2admin/results/16658/change/ for example with the LCZO database). This uses the AJAX_LOOKUP_CHANNELS featureaction_lookup I thought maybe using AutoCompleteSelectField instead of make_ajax_field was the difference but I tried changing it in one of the other forms and I still got the error.

lsetiawan commented 7 years ago

@miguelcleon I commented out autoselect_fields_check_can_add(form, self.model, request.user) in readonlyadmin.py and this seemed to fix the problem. Though I'm not quite sure of the consequences. Thanks.

miguelcleon commented 7 years ago

@lsetiawan I can confirm that commenting out that line prevented the error. It might not be a problem if a readonly user still can't make any changes.

ocefpaf commented 7 years ago

@ocefpaf yes it would be good to have the old version for the moment.

See #106