forked from GithubBackups/healthchecks
Add Project.badge_key so we can preserve the current badge URLs
This commit is contained in:
parent
6b7f212c8a
commit
d102f10a2d
18
hc/accounts/migrations/0019_project_badge_key.py
Normal file
18
hc/accounts/migrations/0019_project_badge_key.py
Normal file
@ -0,0 +1,18 @@
|
||||
# Generated by Django 2.1.5 on 2019-01-12 19:49
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0018_auto_20190112_1426'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='project',
|
||||
name='badge_key',
|
||||
field=models.CharField(blank=True, max_length=150, null=True),
|
||||
),
|
||||
]
|
21
hc/accounts/migrations/0020_auto_20190112_1950.py
Normal file
21
hc/accounts/migrations/0020_auto_20190112_1950.py
Normal file
@ -0,0 +1,21 @@
|
||||
# Generated by Django 2.1.5 on 2019-01-12 19:50
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def set_badge_key(apps, schema_editor):
|
||||
Project = apps.get_model("accounts", "Project")
|
||||
for project in Project.objects.select_related("owner").all():
|
||||
project.badge_key = project.owner.username
|
||||
project.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('accounts', '0019_project_badge_key'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(set_badge_key, migrations.RunPython.noop),
|
||||
]
|
@ -240,6 +240,7 @@ class Project(models.Model):
|
||||
owner = models.ForeignKey(User, models.CASCADE)
|
||||
api_key = models.CharField(max_length=128, blank=True)
|
||||
api_key_readonly = models.CharField(max_length=128, blank=True)
|
||||
badge_key = models.CharField(max_length=150, blank=True, null=True)
|
||||
|
||||
|
||||
class Member(models.Model):
|
||||
|
@ -26,6 +26,7 @@ class SignupTestCase(TestCase):
|
||||
# A project should have been created
|
||||
project = Project.objects.get()
|
||||
self.assertEqual(project.owner, user)
|
||||
self.assertEqual(project.badge_key, user.username)
|
||||
|
||||
# And check should be associated with the new user
|
||||
check = Check.objects.get()
|
||||
|
@ -50,6 +50,7 @@ def _make_user(email):
|
||||
user.save()
|
||||
|
||||
project = Project(owner=user)
|
||||
project.badge_key = user.username
|
||||
project.save()
|
||||
|
||||
# Ensure a profile gets created
|
||||
|
Loading…
x
Reference in New Issue
Block a user