def sentry_create_user(username, password, admin=False): model = sentry_find_user(username) existing = model is not None if not existing: model = User() model.username = username model.is_superuser = admin model.set_password(password) model.save() return model, existing
react_project = Project.objects.filter(name='React').first() if not react_project: react_project = Project() react_project.team = team react_project.name = 'React' react_project.organization = organization react_project.save() react_project.add_team(team) react_project.save() user = User.objects.filter(username='******').first() if not user: user = User() user.username = '******' user.email = 'admin@localhost' user.is_superuser = True user.set_password('admin') user.save() member = OrganizationMember.objects.create( organization=organization, user=user, role='owner', ) OrganizationMemberTeam.objects.create( organizationmember=member, team=team, )
#!/srv/sentry/application/current/bin/python {% from "sentry/map.jinja" import sentry with context %} from sentry.utils.runner import configure configure() from sentry.models import Team, Project, ProjectKey, User, Organization user = User() user.username = '******' user.email = '{{sentry.bootstrap.email}}' user.is_superuser = True user.set_password('{{sentry.bootstrap.password}}') user.save() organization = Organization() organization.name = '{{sentry.bootstrap.organization}}' organization.owner = user organization.save() team = Team() team.organization = organization team.name = '{{sentry.bootstrap.team}}' team.owner = user team.save() project = Project() project.organization = organization project.team = team project.owner = user project.name = '{{sentry.bootstrap.project}}'
organization.name = os.environ.get('TEAM_NAME', 'Aptible') organization.save() team = Team() team.name = os.environ.get('TEAM_NAME', 'Aptible') team.organization = organization team.save() project = Project() project.team = team project.name = 'Default' project.organization = organization project.save() user = User() user.username = os.environ.get('ADMIN_USERNAME', 'aptible') user.email = 'admin@localhost' user.is_superuser = True user.set_password(os.environ['ADMIN_PASSWORD']) user.save() member = OrganizationMember.objects.create( organization=organization, user=user, role='owner', ) OrganizationMemberTeam.objects.create( organizationmember=member, team=team, )
Based on example code from: 'https://docs.sentry.io/server/faq/' """ # Bootstrap the Sentry environment from sentry.models import Organization, OrganizationMember, \ OrganizationMemberTeam, Project, ProjectKey, Team, User from sentry.utils.runner import configure configure() # Make an assumption that if 'admin' -User exists Sentry has been initialized if not User.objects.filter(username='******').exists(): user = User() user.username = '******' user.email = '*****@*****.**' user.is_superuser = True user.set_password('admin') user.save() organization = Organization.objects.filter(slug='sentry')[0] team = Team() team.name = 'COD' team.organization = organization team.save() project = Project() project.team = team project.add_team(team)
#!/usr/bin/env python import sys # Bootstrap the Sentry environment from sentry.utils.runner import configure configure() # Add default superuser from sentry.models import User user = User() user.username = sys.argv[1] user.email = sys.argv[2] user.is_superuser = True user.set_password(sys.argv[3]) user.save()
from sentry.conf.server import env from sentry.utils.runner import configure configure() # Do something crazy from sentry.models import ( Team, Project, ProjectKey, User, Organization, OrganizationMember, OrganizationMemberTeam, Option ) organization = Organization.objects.filter(id=1)[0] team = Team.objects.filter(id=1)[0] user = User() user.username = env('AUTH_LOGIN') user.email = env('AUTH_EMAIL') user.is_superuser = True user.set_password(env('AUTH_PASSWORD')) user.save() member = OrganizationMember.objects.create( organization=organization, user=user, role='owner', ) project = Project() project.slug = 'Default' project.platform = 'php' project.name = 'Default'