-
Notifications
You must be signed in to change notification settings - Fork 12
[872/827] Make staff role fields dependent on staff type #115
base: master
Are you sure you want to change the base?
Conversation
31d4446
to
ce5e0fd
Compare
for staff in records: | ||
first_role = staff.roles.filter(area__isnull=True).first() | ||
if first_role is not None: | ||
first_role.area = staff.area |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we need to copy the location field too from the StaffPage? Maybe only if it has one role only?
first_role = staff.roles.filter(area__isnull=True).first() | ||
if first_role is not None: | ||
first_role.area = staff.area | ||
first_role.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't call clean()
automatically, so you might want to do that and provide a list of pages that fail the new validation. You could just do that manually too, not necessarily in the migration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the newest diff I moved the validation to forms because it would not validate related models properly. I don't think we need to call clean(). Some of the data can stay even if it's not supposed to be there. It will just add unnecessary complexity and if page will be saved later on in the admin site, it'll delete those entries anyway and it will be invisible process.
I also improved migrations to copy location and update draft versions of the pages too.
There's a lot of page that seem that they need upgrading and it's easy enough to make it as migration IMO.
1bc961a
to
c6dd3e4
Compare
c6dd3e4
to
9ee0cd4
Compare
No description provided.