Skip to content

Commit

Permalink
Implement build_number_generator with django
Browse files Browse the repository at this point in the history
  • Loading branch information
Hartmnt committed Apr 6, 2023
1 parent c154382 commit da8fead
Show file tree
Hide file tree
Showing 20 changed files with 785 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
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.
6 changes: 6 additions & 0 deletions mumble_backend/build_number_generator/admin.py
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)
6 changes: 6 additions & 0 deletions mumble_backend/build_number_generator/apps.py
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 mumble_backend/build_number_generator/migrations/0001_initial.py
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.
29 changes: 29 additions & 0 deletions mumble_backend/build_number_generator/models.py
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"
)
]
Loading

0 comments on commit da8fead

Please sign in to comment.