From e53751f4ad01de059455b541112f3127a45dad16 Mon Sep 17 00:00:00 2001 From: dmitriirubanov Date: Sun, 19 Nov 2023 11:12:43 +0400 Subject: [PATCH 1/3] issue 360 * Added filter for oranization.name in repositories_list.html --- templates/components/tables/repositories_list.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/templates/components/tables/repositories_list.html b/templates/components/tables/repositories_list.html index ff5fa361..01054815 100644 --- a/templates/components/tables/repositories_list.html +++ b/templates/components/tables/repositories_list.html @@ -33,9 +33,15 @@ {{ repository.num }} - - {{ repository.name }} - + {% if repository.organization.name == 'Hexlet' %} + + {{ repository.name }} + + {% elif repository.organization.name != 'Hexlet' %} + + {{ repository.full_name }} Fork + + {% endif %} {% if not organization %} {{ repository.organization.name }} From 56012c41ec19749a0c3fa3671beba39e9ea74bb3 Mon Sep 17 00:00:00 2001 From: dmitriirubanov Date: Tue, 21 Nov 2023 16:27:32 +0400 Subject: [PATCH 2/3] issue 360 * Added bool field "fork" to Repository model * Added saving this field to update_or_create_record * Added check for fork in repositories_list template --- contributors/models/repository.py | 1 + contributors/utils/misc.py | 1 + templates/components/tables/repositories_list.html | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/contributors/models/repository.py b/contributors/models/repository.py index a21b10ce..9c85df22 100644 --- a/contributors/models/repository.py +++ b/contributors/models/repository.py @@ -43,6 +43,7 @@ class Repository(CommonFields): blank=True, ) full_name = models.CharField(_("full name"), max_length=FULL_NAME_LENGTH) + fork = models.BooleanField(_("fork"), default=False) is_visible = models.BooleanField(_("visible"), default=True) labels = models.ManyToManyField( Label, diff --git a/contributors/utils/misc.py b/contributors/utils/misc.py index 3541f37c..7ef50862 100644 --- a/contributors/utils/misc.py +++ b/contributors/utils/misc.py @@ -47,6 +47,7 @@ def update_or_create_record(cls, github_resp, additional_fields=None): else None ), 'full_name': github_resp['full_name'], + 'fork': github_resp['fork'], }, 'Contributor': lambda: { 'login': github_resp['login'], diff --git a/templates/components/tables/repositories_list.html b/templates/components/tables/repositories_list.html index 01054815..37f9c8d6 100644 --- a/templates/components/tables/repositories_list.html +++ b/templates/components/tables/repositories_list.html @@ -33,13 +33,13 @@ {{ repository.num }} - {% if repository.organization.name == 'Hexlet' %} + {% if repository.fork is True %} - {{ repository.name }} + {{ repository.full_name }} Fork - {% elif repository.organization.name != 'Hexlet' %} + {% else %} - {{ repository.full_name }} Fork + {{ repository.name }} {% endif %} From 89478af56d79f523fcd9eeb21d1e923044badf35 Mon Sep 17 00:00:00 2001 From: dmitriirubanov Date: Tue, 21 Nov 2023 16:28:00 +0400 Subject: [PATCH 3/3] issue 360 * Added bool field "fork" to Repository model * Added saving this field to update_or_create_record * Added check for fork in repositories_list template --- contributors/migrations/0014_repository_fork.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 contributors/migrations/0014_repository_fork.py diff --git a/contributors/migrations/0014_repository_fork.py b/contributors/migrations/0014_repository_fork.py new file mode 100644 index 00000000..b38e942d --- /dev/null +++ b/contributors/migrations/0014_repository_fork.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.4 on 2023-11-21 12:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("contributors", "0013_alter_label_name"), + ] + + operations = [ + migrations.AddField( + model_name="repository", + name="fork", + field=models.BooleanField(default=False, verbose_name="fork"), + ), + ]