Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MariuszWisniewski/fd405c263ea5e7c4571e51df6af33d61 to your computer and use it in GitHub Desktop.
Save MariuszWisniewski/fd405c263ea5e7c4571e51df6af33d61 to your computer and use it in GitHub Desktop.
Add usernames to user profiles of all Syncano users
import syncano
from syncano.models import User
from syncano.models import Object
syncano.connect(api_key='ACCOUNT_KEY', instance_name=META['instance'])
def add_username_to_user(user):
print user.id
user_profile = Object.please.list(
class_name='user_profile'
).filter(owner__eq=user.id).first()
print user_profile
Object.please.update(
id=user_profile.id,
class_name='user_profile',
other_permissions='read',
username=user.username
)
users = User.please.list()
for user in users:
print "Adding username and read permissions for user {user}".format(user=user.username)
add_username_to_user(user)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment