Commit 337bbb4c authored by Guilhem Saurel's avatar Guilhem Saurel
Browse files

archived

parent a1f7a23c
Pipeline #2120 failed with stages
in 1 minute and 9 seconds
......@@ -8,7 +8,7 @@ class ProjectFilter(django_filters.rest_framework.FilterSet):
class Meta:
model = models.Project
fields = ('name', 'from_gepetto')
fields = ('name', 'from_gepetto', 'archived')
class ContributorFilter(django_filters.rest_framework.FilterSet):
......
# Generated by Django 2.1.3 on 2019-01-10 17:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('rainboard', '0025_auto_20181217_1536'),
]
operations = [
migrations.AddField(
model_name='project',
name='archived',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='repo',
name='archived',
field=models.BooleanField(default=False),
),
]
......@@ -14,6 +14,7 @@ from django.utils.safestring import mark_safe
import git
import requests
from autoslug import AutoSlugField
from ndh.models import Links, NamedModel, TimeStampedModel
from ndh.utils import enum_to_choices, query_sum
......@@ -183,6 +184,7 @@ class Project(Links, NamedModel, TimeStampedModel):
debug = models.BooleanField(default=False)
from_gepetto = models.BooleanField(default=True)
cmake_name = models.CharField(max_length=200, blank=True, null=True)
archived = models.BooleanField(default=False)
def save(self, *args, **kwargs):
self.name = valid_name(self.name)
......@@ -406,6 +408,7 @@ class Repo(TimeStampedModel):
clone_url = models.URLField(max_length=200)
travis_id = models.PositiveIntegerField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
archived = models.BooleanField(default=False)
def __str__(self):
return self.name
......@@ -450,7 +453,14 @@ class Repo(TimeStampedModel):
def api_update(self):
data = self.api_data()
if data:
return getattr(self, f'api_update_{self.forge.get_source_display()}')(data)
if data['archived']:
if self.project.main_repo() == self:
self.project.archived = True
self.project.save()
self.archived = True
self.save()
else:
return getattr(self, f'api_update_{self.forge.get_source_display()}')(data)
def api_update_gitlab(self, data):
update_gitlab(self.forge, data)
......@@ -831,7 +841,7 @@ class Tag(models.Model):
class GepettistQuerySet(models.QuerySet):
def gepettist(self):
return self.filter(projects__from_gepetto=True)
return self.filter(projects__from_gepetto=True, projects__archived=False)
class Contributor(models.Model):
......@@ -852,7 +862,7 @@ class Contributor(models.Model):
return ', '.join(str(mail) for mail in self.contributormail_set.filter(invalid=False))
def contributed(self):
return ', '.join(str(project) for project in self.projects.filter(from_gepetto=True))
return ', '.join(str(project) for project in self.projects.filter(from_gepetto=True, archived=False))
class ContributorName(models.Model):
......
......@@ -25,7 +25,7 @@ class ProjectSerializer(serializers.ModelSerializer):
class Meta:
model = models.Project
fields = ('id', 'name', 'slug', 'public', 'main_namespace', 'main_forge', 'license', 'homepage', 'description',
'version', 'updated', 'tests', 'docs', 'debug', 'from_gepetto', 'created', 'updated')
'version', 'updated', 'tests', 'docs', 'debug', 'from_gepetto', 'archived', 'created', 'updated')
class RepoSerializer(serializers.ModelSerializer):
......
......@@ -33,7 +33,7 @@ class ProjectTable(StrippedTable):
class Meta:
model = models.Project
fields = ('main_namespace', 'name', 'public', 'from_gepetto', 'license', 'homepage', 'updated', 'version')
fields = ('main_namespace', 'name', 'public', 'from_gepetto', 'archived', 'license', 'homepage', 'updated', 'version')
def render_name(self, record):
return record.get_link()
......
......@@ -36,6 +36,7 @@
<dt class="col-3 text-right">Has docs</dt> <dd class="col-9">{{ project.docs|yesno:"✔,✘" }}</dd>
<dt class="col-3 text-right">Also build in Debug</dt> <dd class="col-9">{{ project.debug|yesno:"✔,✘" }}</dd>
<dt class="col-3 text-right">From Gepetto</dt> <dd class="col-9">{{ project.from_gepetto|yesno:"✔,✘" }}</dd>
<dt class="col-3 text-right">Archived</dt> <dd class="col-9">{{ project.archived|yesno:"✔,✘" }}</dd>
<dt class="col-3 text-right">Dependencies</dt> <dd class="col-9">{{ project.print_deps }}</dd>
<dt class="col-3 text-right">Reverse Dependencies</dt> <dd class="col-9">{{ project.print_rdeps }}</dd>
</dl>
......
......@@ -29,7 +29,7 @@ class ProjectsView(SingleTableMixin, FilterView):
class GepettoProjectsView(ProjectsView):
queryset = models.Project.objects.filter(from_gepetto=True)
queryset = models.Project.objects.filter(from_gepetto=True, archived=False)
class ProjectView(DetailView):
......@@ -115,9 +115,10 @@ def docker(request):
def graph_svg(request):
with open('/tmp/graph', 'w') as f:
print('digraph { rankdir=LR;', file=f)
for project in models.Project.objects.filter(from_gepetto=True):
for project in models.Project.objects.filter(from_gepetto=True, archived=False):
print(f'{{I{project.pk} [label="{project}" URL="{project.get_absolute_url()}"];}}', file=f)
for dep in models.Dependency.objects.filter(project__from_gepetto=True, library__from_gepetto=True):
for dep in models.Dependency.objects.filter(project__from_gepetto=True, library__from_gepetto=True,
project__archived=False, library__archived=False):
print(f'I{dep.library.pk} -> I{dep.project.pk};', file=f)
print('}', file=f)
svg = run(['dot', '/tmp/graph', '-Tsvg'], stdout=PIPE).stdout.decode()
......
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