Commit 547e63aa authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

keep_doc

parent 3c96822c
Pipeline #505 passed with stages
in 54 seconds
......@@ -33,3 +33,4 @@ echo TRAVIS_TOKEN=xxx >> .env
## TODO
- fix urls (https://api.github.com/repos/stack-of-tasks/pinocchio)
- ./bootstrap in robotpkg for `make show-var VARNAME=…`
# Generated by Django 2.0.4 on 2018-04-06 14:19
from django.db import migrations, models
from django.db.models import F, Q
from rainboard.utils import SOURCES
def keep_doc(apps, schema_editor):
apps.get_model('rainboard', 'Branch').objects.filter(
Q(name__endswith='master') | Q(name__endswith='devel'),
repo__namespace=F('project__main_namespace'),
repo__forge__source=SOURCES.gitlab,
).update(keep_doc=True)
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0008_remove_article'),
]
operations = [
migrations.AddField(
model_name='branch',
name='keep_doc',
field=models.BooleanField(default=False),
),
migrations.RunPython(keep_doc),
]
......@@ -438,6 +438,7 @@ class Branch(TimeStampedModel):
updated = models.DateTimeField(blank=True, null=True)
repo = models.ForeignKey(Repo, on_delete=models.CASCADE, null=True)
deleted = models.BooleanField(default=False)
keep_doc = models.BooleanField(default=False)
def __str__(self):
return self.name
......
......@@ -16,4 +16,5 @@ urlpatterns = [
path('project/<str:slug>/images', views.ProjectImagesView.as_view(), name='project-images'),
path('project/<str:slug>/contributors', views.ProjectContributorsView.as_view(), name='project-contributors'),
path('project/<str:slug>/gitlab-ci.yml', views.ProjectGitlabView.as_view(), name='project-gitlab'),
path('doc', views.json_doc, name='doc'),
]
from django.http.response import JsonResponse
from django.views.generic import DetailView
from django_filters.views import FilterView
......@@ -83,3 +84,11 @@ class ContributorsView(SingleTableMixin, DistinctMixin, FilterView):
model = models.Contributor
table_class = tables.ContributorProjectTable
filterset_class = filters.ContributorFilter
def json_doc(request):
"""
Get the list of project / namespace / branch of which we want to keep the doc
"""
return JsonResponse({'ret': [(b.project.slug, b.repo.namespace.slug, b.name.split('/', maxsplit=2)[2]) for b in
models.Branch.objects.filter(keep_doc=True)]})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment