def setprimary(account, picture):
    """ Set picture as the galleries primary picture. """
    gallery = picture.gallery
    _assert_can_edit(account, gallery)
    gallery.primary = picture
    gallery.save()