Skip to content

Conversation

@abhinavk96
Copy link
Contributor

@abhinavk96 abhinavk96 commented Sep 2, 2019

Fixes #6434
Fixes #6191

Short description of what this resolves:

Adds fields to accommodate complex custom form values in sessions, speakers and attendees.

@codecov
Copy link

codecov bot commented Sep 2, 2019

Codecov Report

Merging #6435 into development will increase coverage by <.01%.
The diff coverage is 82.35%.

Impacted file tree graph

@@               Coverage Diff               @@
##           development    #6435      +/-   ##
===============================================
+ Coverage        64.51%   64.52%   +<.01%     
===============================================
  Files              291      292       +1     
  Lines            15117    15147      +30     
===============================================
+ Hits              9753     9773      +20     
- Misses            5364     5374      +10
Impacted Files Coverage Δ
app/api/schema/settings.py 100% <100%> (ø) ⬆️
...ts/all/integration/api/validation/test_sessions.py 97.14% <100%> (ø) ⬆️
app/models/speaker.py 94.66% <100%> (+0.14%) ⬆️
app/models/setting.py 91.58% <100%> (+0.08%) ⬆️
app/models/ticket_holder.py 84.31% <100%> (+0.31%) ⬆️
app/models/session.py 90.52% <100%> (+0.2%) ⬆️
app/api/schema/sessions.py 87.34% <100%> (+0.49%) ⬆️
app/api/helpers/validations.py 50% <50%> (ø)
app/api/schema/speakers.py 97.77% <80%> (-2.23%) ⬇️
app/api/schema/attendees.py 98.24% <80%> (-1.76%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb8d721...44c80f4. Read the comment docs.

@iamareebjamal
Copy link
Member

This will allow users to add arbritrarily nested JSON to the DB. Please add validation for only flat JSON

@abhinavk96
Copy link
Contributor Author

@iamareebjamal Added a validation check to only allow flattened JSON. Verified locally by passing a two-level deep JSON object.

@validates_schema(pass_original=True)
def validate_json(self, data, original_data):
if data.get('complex_field_values'):
if any(isinstance(i, dict) for i in data['complex_field_values'].values()):
Copy link
Member

@iamareebjamal iamareebjamal Sep 4, 2019

Choose a reason for hiding this comment

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

{
  "a": [{... big nested data ...}, {... big nested data ...}, {... big nested data ...}] 
}

This will be supported

Copy link
Member

Choose a reason for hiding this comment

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

Also, let's add a limit to the fields in settings. By default, allow only 30 items. I think it is fair. If more are required, then it can be changed by the admin

Copy link
Contributor Author

Choose a reason for hiding this comment

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

{
  "a": [{... big nested data ...}, {... big nested data ...}, {... big nested data ...}] 
}

This will be supported

@iamareebjamal for this can we impose that the value has to be a string or number or null, that will eliminate the possibility of a list or other unsupported types.

Copy link
Member

@iamareebjamal iamareebjamal Sep 4, 2019

Choose a reason for hiding this comment

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

Agree. string, number, null, or boolean

@abhinavk96 abhinavk96 force-pushed the alpha branch 2 times, most recently from cefdc65 to f1d74d3 Compare September 4, 2019 04:54
@abhinavk96
Copy link
Contributor Author

@iamareebjamal Please take a look now.

@abhinavk96 abhinavk96 merged commit a85bde9 into fossasia:development Sep 4, 2019
@fossasia fossasia deleted a comment Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add JSON column to attendees, sessions and speakers Propose and Implement a schema for complex custom forms

3 participants