Created
June 24, 2016 20:52
-
-
Save MariuszWisniewski/fd405c263ea5e7c4571e51df6af33d61 to your computer and use it in GitHub Desktop.
Add usernames to user profiles of all Syncano users
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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