-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement build_number_generator with django
- Loading branch information
Showing
20 changed files
with
785 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,38 @@ | ||
# backend-services | ||
|
||
Scripts used to power the Mumble public infrastructure backend (e.g. public server list) | ||
|
||
|
||
## Development | ||
|
||
Enter the Django project folder ``mumble_backend``. Call ``source setup`` | ||
to create a new venv which automatically installs Django and activates it. | ||
|
||
Create the database tables with: | ||
``` | ||
python manage.py migrate | ||
``` | ||
|
||
Start the development server with: | ||
``` | ||
python manage.py runserver | ||
``` | ||
|
||
Run tests with: | ||
``` | ||
python manage.py test | ||
``` | ||
|
||
Create an admin account for the admin interface with: | ||
``` | ||
python manage.py createsuperuser | ||
``` | ||
|
||
Auto format code with: | ||
``` | ||
black . | ||
``` | ||
|
||
## Production | ||
|
||
TBD |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.contrib import admin | ||
|
||
from .models import Series, Build | ||
|
||
admin.site.register(Series) | ||
admin.site.register(Build) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class BuildNumberGeneratorConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "build_number_generator" |
62 changes: 62 additions & 0 deletions
62
mumble_backend/build_number_generator/migrations/0001_initial.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Generated by Django 4.1.7 on 2023-04-02 10:26 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
initial = True | ||
|
||
dependencies = [] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Series", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("name", models.CharField(max_length=20, unique=True)), | ||
("created_on", models.DateTimeField(auto_now_add=True)), | ||
], | ||
options={ | ||
"verbose_name_plural": "series", | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name="Build", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("commit_hash", models.CharField(max_length=128)), | ||
("build_number", models.PositiveIntegerField()), | ||
("created_on", models.DateTimeField(auto_now_add=True)), | ||
( | ||
"series", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to="build_number_generator.series", | ||
), | ||
), | ||
], | ||
), | ||
migrations.AddConstraint( | ||
model_name="build", | ||
constraint=models.UniqueConstraint( | ||
fields=("series", "commit_hash"), name="commit_unique_in_series" | ||
), | ||
), | ||
] |
Empty file.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from django.db import models | ||
|
||
|
||
class Series(models.Model): | ||
name = models.CharField(max_length=20, unique=True) | ||
created_on = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return "%s.x" % (self.name) # e.g. 1.4.x | ||
|
||
class Meta: | ||
verbose_name_plural = "series" | ||
|
||
|
||
class Build(models.Model): | ||
series = models.ForeignKey(Series, on_delete=models.PROTECT) | ||
commit_hash = models.CharField(max_length=128) | ||
build_number = models.PositiveIntegerField() | ||
created_on = models.DateTimeField(auto_now_add=True) | ||
|
||
def __str__(self): | ||
return "%s.%i" % (self.series.name, self.build_number) # e.g. 1.4.142 | ||
|
||
class Meta: | ||
constraints = [ | ||
models.UniqueConstraint( | ||
fields=["series", "commit_hash"], name="commit_unique_in_series" | ||
) | ||
] |
Oops, something went wrong.