Project

General

Profile

User Story #1858

Change defined values for different fields in technology questionnaire edition 2018

Added by Redmine Admin over 5 years ago. Updated almost 5 years ago.

Status:
Closed
Priority:
High
Assignee:
Category:
-
Target version:
Start date:
12 Jul 2019
Due date:
% Done:

0%

Estimated time:
Resolution:

Description

Adaptation of the list of predefined values for plants, annual cropping systems, perennial crops, trees, etc
in question '3.2 Current land use type(s) where the Technology is applied'

The list has to conform to the list in the attached word file.


Files

LUT lists_FINAL.docx (48.7 KB) LUT lists_FINAL.docx Final LUT list Redmine Admin, 12 Jul 2019 15:07
LUT lists-newvalues.xlsx (11.4 KB) LUT lists-newvalues.xlsx Updated List Values Brahadeesh Dheenadayalan_Sivakami, 02 Sep 2019 04:10
apps_configuration.tar (10 KB) apps_configuration.tar Scripts for new values Brahadeesh Dheenadayalan_Sivakami, 06 Sep 2019 07:44
#1

Updated by Kurt Gerber over 5 years ago

  • Assignee changed from Brahadeesh Dheenadayalan_Sivakami to Kurt Gerber

Guhan asks:

I am stuck trying to figure out how to add the new list-item values. When I run the existing fixtures the new CBP edition 2018 values are not inserted into the database tables (configuration_key, configuration_value and configuration_translation).
I found the editions script that has all the 2018 values (for example cereals-maize) which are returned as a dictionary but I am unable to figure out how to run this script. Is there some documentation I am missing?
To maintain the existing foreign key relationships I was thinking of using a fixture to append the new values but I am not sure this is the best approach.

#2

Updated by Kurt Gerber over 5 years ago

  • Status changed from Accepted to In Progress
#3

Updated by Kurt Gerber over 5 years ago

  • Assignee changed from Kurt Gerber to Brahadeesh Dheenadayalan_Sivakami

I had to reach my backstopping support for this question (Sebastian/Lukas). I got the following answer:

The configuration for the 2018 edition of the Technologies questionnaire is inserted via a script, it can be run using `python manage.py runscript technologies_2018`. This will create a new configuration (in the DB table `configuration_configuration` with the values for the edition 2018. The script itself is in `apps/configuration/scripts/technologies_2018.py` and calls the edition code in `apps/configuration/editions/technologies_2018.py`.

If you want to add new values without creating a new edition, I'd suggest to also create a script (e.g. `technologies_2018_1`) which calls code (e.g. `apps/configuration/editions/technologies_2018_1.py`) to update the already existing edition 2018 of the Technologies questionnaire. If your edition class inherits from `Edition` in `apps/configuration/editions/base.py`, you could reuse some methods defined there (e.g. `create_new_value`). You should make sure that no new edition is created (I think if you set code = 'technologies' and edition = 2018, it should update the existing edition 2018 instead of creating a new one).

Please note that you should only add new values but not edit existing questions or values (except their translations). Otherwise existing questionnaires cannot be updated anymore if they reference the edited question.

#4

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

Hi Kurt,
I have successfully added scripts (editions/technologies_2018_1 & scripts/technologies_2018_1) to append the new items. I will modify the items based on the list you shared which I have attached here.
One issue I found with my testing is that each time I run the script to append the values, it resets the configuration back to the 2015 edition. This is fixed by running the technologies_2018 script but I don't think this is the approach to use on production. I did set the code and edition to technologies and 2018 in the new script.

If you want I can push my feature branch to Github so you can check my scripts.

Sorry for the trouble. Any help is appreciated.

Kurt Gerber wrote:

I had to reach my backstopping support for this question (Sebastian/Lukas). I got the following answer:

The configuration for the 2018 edition of the Technologies questionnaire is inserted via a script, it can be run using `python manage.py runscript technologies_2018`. This will create a new configuration (in the DB table `configuration_configuration` with the values for the edition 2018. The script itself is in `apps/configuration/scripts/technologies_2018.py` and calls the edition code in `apps/configuration/editions/technologies_2018.py`.

If you want to add new values without creating a new edition, I'd suggest to also create a script (e.g. `technologies_2018_1`) which calls code (e.g. `apps/configuration/editions/technologies_2018_1.py`) to update the already existing edition 2018 of the Technologies questionnaire. If your edition class inherits from `Edition` in `apps/configuration/editions/base.py`, you could reuse some methods defined there (e.g. `create_new_value`). You should make sure that no new edition is created (I think if you set code = 'technologies' and edition = 2018, it should update the existing edition 2018 instead of creating a new one).

Please note that you should only add new values but not edit existing questions or values (except their translations). Otherwise existing questionnaires cannot be updated anymore if they reference the edited question.

#5

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

  • Assignee changed from Brahadeesh Dheenadayalan_Sivakami to Kurt Gerber
#6

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Kurt Gerber to Brahadeesh Dheenadayalan_Sivakami

Could you please push your changes (scripts) in a new branch (In git-flow it is called a feature branch) to github?
If you feel unsure, just attach the two scripts.

#7

Updated by Kurt Gerber about 5 years ago

Sorry, my error, I forgot that you can only do a pull request.
So, could you please do a pull request?

#8

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

Hi Kurt,
I have the code on a feature branch but I am not sure how to send a pull request since that branch does not exist on GitHub? Did you mean pull request to develop?
Nonetheless, I've attached the scripts I have developed in their respective folders <editions and scripts>.

Kurt Gerber wrote:

Sorry, my error, I forgot that you can only do a pull request.
So, could you please do a pull request?

#9

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Kurt Gerber to Lukas Vonlanthen

Lukas,
Please read the comments from Guhan and we would be thankfull for a little hint.

#10

Updated by Lukas Vonlanthen about 5 years ago

  • Assignee changed from Lukas Vonlanthen to Brahadeesh Dheenadayalan_Sivakami

I am afraid the information I have given you earlier was not entirely correct. I am very sorry about that - it has been a while since I have worked with QCAT in depth.

You are right about the script resetting the previous edition 2018 (the reason being that Edition.get_base_configuration_data() excludes the current edition, thus returning the data of the edition 2015 as the base data for the changes).

I forgot that the edition scripts can be run repeatedly, even if the edition was already applied. So running python manage.py runscript technologies_2018 on the server again without any changes to the edition does not have any impact. It also means that it is probably easier to add the new operations to the existing ones in apps/configuration/editions/technologies_2018.py and then run the script again, which will only create the new values as the others already exist.

Again, this should only be done with new questions or values. It should not be used to modify existing questions or values.

I hope this helps?

Just a quick note about Pull Requests on Github: In order to create a PR on Github, you have to push your (feature-)branch first, then create a PR based on this branch. See https://help.github.com/en/articles/about-pull-requests.

#11

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

  • Status changed from In Progress to Feedback
  • Assignee changed from Brahadeesh Dheenadayalan_Sivakami to Kurt Gerber

Hi Kurt,
I have generated a pull request for this task.
Expecting your feedback and comments on my first submission!

Thanks,
Guhan

#12

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Kurt Gerber to Lukas Vonlanthen

Lukas, can you please review the pull request?

#13

Updated by Lukas Vonlanthen about 5 years ago

The pull request (https://github.com/CDE-UNIBE/qcat/pull/48) looks good to me code-wise! I just added a comment about the release notes, but this is more a formal question. Once that is cleared, I am happy to approve your first PR!

#14

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Lukas Vonlanthen to Brahadeesh Dheenadayalan_Sivakami

Concerning the proposal from Lukas:
Please add it a the end by adding: 'Update October 2019: Question 3.2: New annual crops were added...

#15

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

  • Assignee changed from Brahadeesh Dheenadayalan_Sivakami to Kurt Gerber

Hi Kurt and Lukas,
I have made the requested change to the previous commit. This should now reflect in the existing pull request.

Thanks,
Guhan

#16

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

A quick question regarding this change issue.
Does the apps/configuration/editions/technologies_2018.py script need to be run so that the list-values are updated and visible on https://qcat-dev.wocat.net/?

Thanks,
Guhan

#17

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Kurt Gerber to Lukas Vonlanthen

Hi Lukas, could you please answer Guhan's last question?
Thanks.

#18

Updated by Lukas Vonlanthen about 5 years ago

Yes, you will need to run the script (python manage.py runscript technologies_2018) on the server (in /srv/webapps/qcat-dev) so that the values are updated. You will most probably have to activate the virtual environment first (source /srv/webapps/qcat-dev/virtualenv/bin/activate).

I hope this helps?

Best regards,
Lukas

#19

Updated by Kurt Gerber about 5 years ago

  • Assignee changed from Lukas Vonlanthen to Tatenda Lemann

The new values below section 3 are now added in https://qcat-dev.wocat.net.
Could you, or anybody else, please check, if that is ok?

When you give me the 'ok', I will deploy it on production (https://qcat.wocat.net).

#20

Updated by Brahadeesh Dheenadayalan_Sivakami about 5 years ago

  • Assignee changed from Tatenda Lemann to Kurt Gerber

Hi Kurt,
I can confirm that the new values are now showing up in their respective dropdown lists.

Thanks,
Guhan

#21

Updated by Kurt Gerber about 5 years ago

  • Status changed from Feedback to Resolved
#22

Updated by Kurt Gerber almost 5 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF