You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Implement a per account setting for system of measurement
Dependencies
Database/backend design
Translation service
AC
As a user, When I go to my account settings page, Then there is a setting for unit of measurement
As a user, When I set my unit of measurement setting, all forms display a default measurement that corresponds with the field's unit.
Notes
Design not set yet, but leaning towards setting all the data in the database as metric, then adding a backend translation layer that would make any calculations before passing them to the front end. Look into middleware or custom filters.
Development Tasks
Add a field to the user model to store the system of measurement
"imperial" or "metric".
On login, retrieve user's system of measurement preference from the database and store it in the session object
suggestion: session['system_of_measurement']
Use the session variable to render the correct unit on the forms. (another ticket to create the generic measurements component)
When the form is submitted, retrieve the system_of_measurement value from the session object and use it to convert the weight to the appropriate units.
classUser:
def__init__(self, id, system_of_measurement):
self.id=id# ... and so onself.system_of_measurement=system_of_measurementclassWeightForm(FlaskForm):
weight=FloatField('Weight', validators=[InputRequired())
system=SelectField('System of Measurement', choices=[('imperial', 'Imperial'), ('metric', 'Metric')])
submit=SubmitField('Submit')
@app.route('/tracker', methods=['GET', 'POST'])deftracker():
# check for user code# init form stuff hereform=WeightForm()
form.system.default=user.system_of_measurement# for the default values (dbl check this) -> form.process()ifform.validate_on_submit():
weight=form.weight.data# on submit, send to some other back end service to make the translations before committing to the database
The text was updated successfully, but these errors were encountered:
Summary
Implement a per account setting for system of measurement
Dependencies
AC
Notes
Design not set yet, but leaning towards setting all the data in the database as metric, then adding a backend translation layer that would make any calculations before passing them to the front end. Look into middleware or custom filters.
Development Tasks
The text was updated successfully, but these errors were encountered: