#1764 Add custom drop down lists to custom fields
Merged by pingou. Opened by mreynolds.
mreynolds/pagure dropdown  into  master

Download 1764.patch

This patch adds an option to create a "List" as a custom field. To do this we need to add "key_data" to the issueKey model for storing the list items.Currently this is only used by "lists", so other field types ignore and remove the data if it's set.

https://pagure.io/pagure/issue/1748

Docstring ? (here and below :))

What about None or [] then?

What about making this a JSON blob as we do for milestones/priorities and such?

2 new commits added

  • Convert field data to json
  • Added docstring to migration script, and used None for the data pruging of non-lists

No need to put the list in a dict, you can directly put the list in the json.dumps(), which will also make the getter much simpler

I think we should keep this part as dum as possible and do the split in the controller

Same here, imho, it should return the list, not a string.

Side note: You can concatenate a list using ', '.join(list) for example:

>>> ', '.join(['a', 'b', 'c'])
'a, b, c'

Which also simplifies the code quite a bit :)

Note that is field.data returns a list, you can then use {{ field.data | join(', ') }}

I don't want to return a list, this string is directly used by the html page. Its much harder to do this splitting in html/jinja than it is to do it here. However, I will use your concatenation though

What are you proposing exactly? This section does the normalization of removing white spaces around the commas. We need this.

Will this add an unwanted comma after the last item? I need to test it...

Yup, you're right. I'll revise this.

Actually I might be able to remove this function based off one of your other comments...

I won't add a trailing coma no:

>>> ', '.join(['a', 'b', 'c'])
'a, b, c'

Agreed, but I think we could move it above (going to add a comment to where I think we could place it)

I think this is the place where I would do the split on , and .strip()

rebased

Applied recommended changes and rebased...

I guess we should rename the argument then list_str, maybe data_obj?

I would prefer we do something like:

if key.name == 'bugzilla':
    self.assertNotNone(key.data)

Or, even better that we check precisely what key.data is :)

Same as above if possible :)

Few nitpicking the rest is looking good, I'm going to test it locally

1 new commit added

  • Adjust test case

I think there is typo here This is required ...

     I think there is typo here This is required ...

No typo here - this is correct. Perhaps it's not the best wording though. I'll change it...

1 new commit added

  • Revise comment in migration script

You can drop the () ;-)

assertFalse item not in list? Could we avoid the double negation here? :)

1 new commit added

  • Fix testcase

rebased

Added a few commits and rebased :)

1 new commit added

  • Move the custom field block to the right and fix indentation in the html

This is looking all good to me and local testing seem fine as well :)

Pull-Request has been merged by pingou

Metadata