forked from onecodex/onpremise
/
bootstrap.py
47 lines (39 loc) · 1.18 KB
/
bootstrap.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import os
# Bootstrap the Sentry environment
from sentry.utils.runner import configure
configure()
# Then import the models
from sentry.models import (
Team, Project, User, Organization, OrganizationMember,
OrganizationMemberTeam
)
# Create an organization, team, and user if there are *no* users
# in the install (bootstrap 1 time only)
if not User.objects.all():
organization = Organization()
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,
)