Пример #1
0
 def _clone_event_roles(self, new_event):
     attrs = get_simple_column_attrs(EventRole) | {'members'}
     for old_event_role in self.old_event.roles:
         event_role = EventRole()
         event_role.populate_from_attrs(old_event_role, attrs)
         new_event.roles.append(event_role)
         self._event_role_map[old_event_role] = event_role
Пример #2
0
def _fix_role_principals(principals, get_event):
    role_attrs = get_simple_column_attrs(EventRole) | {'members'}
    for p in principals:
        click.echo(f'Fixing {p}')
        event = get_event(p)
        try:
            event_role = [
                r for r in event.roles if r.code == p.event_role.code
            ][0]
        except IndexError:
            event_role = EventRole(event=event)
            event_role.populate_from_attrs(p.event_role, role_attrs)
        else:
            click.echo(f'  using existing role {event_role}')
        p.event_role = event_role
    db.session.flush()