Skip to content

Commit

Permalink
Merge pull request #1421 from nextcloud/feature/is-orphan
Browse files Browse the repository at this point in the history
feat: add orphan/maintained status to apps
  • Loading branch information
edward-ly authored Jul 25, 2024
2 parents 650592a + c46aa9d commit f55c253
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 5 deletions.
1 change: 1 addition & 0 deletions nextcloudappstore/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def post(self, request):
if app.ownership_transfer_enabled:
app.owner = request.user
app.ownership_transfer_enabled = False
app.is_orphan = False
elif app.owner != request.user:
msg = "Only the app owner is allowed to update the certificate"
raise PermissionDenied(msg)
Expand Down
2 changes: 2 additions & 0 deletions nextcloudappstore/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class AppAdmin(TranslatableAdmin):
"summary",
"is_featured",
"ownership_transfer_enabled",
"is_orphan",
"is_integration",
"approved",
)
Expand All @@ -81,6 +82,7 @@ class AppAdmin(TranslatableAdmin):
"is_featured",
"last_release",
"ownership_transfer_enabled",
"is_orphan",
"is_integration",
"approved",
)
Expand Down
18 changes: 18 additions & 0 deletions nextcloudappstore/core/migrations/0031_app_is_orphan.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.14 on 2024-07-24 00:31

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('core', '0030_remove_apprelease_aa_proto_and_more'),
]

operations = [
migrations.AddField(
model_name='app',
name='is_orphan',
field=models.BooleanField(default=False, verbose_name='Orphan'),
),
]
1 change: 1 addition & 0 deletions nextcloudappstore/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class App(TranslatableModel):
)
authors = ManyToManyField("AppAuthor", blank=True, related_name="apps", verbose_name=_("App authors"))
is_featured = BooleanField(verbose_name=_("Featured"), default=False)
is_orphan = BooleanField(verbose_name=_("Orphan"), default=False)
rating_recent = FloatField(verbose_name=_("Recent rating"), default=0.5)
rating_overall = FloatField(verbose_name=_("Overall rating"), default=0.5)
rating_num_recent = IntegerField(verbose_name=_("Number of recently submitted ratings"), default=0)
Expand Down
15 changes: 15 additions & 0 deletions nextcloudappstore/core/static/assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ body {
border-radius: 3px;
}

.tag-danger {
color: var(--color-error);
border: 1px solid var(--color-error-hover);
}

#footer {
position: absolute;
bottom: 0;
Expand Down Expand Up @@ -1121,3 +1126,13 @@ form .form-group input[type=checkbox] {
.account-content {
margin-bottom: 60px;
}

.transfer-apps th:not(:first-child),
.transfer-apps td:not(:first-child) {
text-align: center;
}

.transfer-apps form {
display: flex;
justify-content: center;
}
4 changes: 3 additions & 1 deletion nextcloudappstore/core/templates/app/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@
</div>
{% endif %}
<div class="header-wrap">
<h1>{{ object.name }}</h1>{% if object.is_featured %}<span class="tag featured">{% trans "Featured" %}</span>{% endif %}
<h1>{{ object.name }}</h1>
{% if object.is_featured %}<span class="tag featured">{% trans "Featured" %}</span>{% endif %}
{% if object.is_orphan %}<span class="tag tag-danger">{% trans "Orphan / Looking for Maintainer" %}</span>{% endif %}
</div>
<div class="app-meta col-md-4 col-sm-12">
<section>
Expand Down
26 changes: 23 additions & 3 deletions nextcloudappstore/user/templates/user/transfer-apps.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,32 @@
<h1>{% trans "Transfer Apps" %}</h1>
<section>
<p>{% trans 'To transfer an app to a new owner you must first unlock the app. A user can then take control of the app by registering it again on the app register page in the app developer menu.' %}</p>
<p>{% trans 'Don\'t have a new owner yet? You can mark the app as orphaned to indicate that you are looking for a new owner. Once the transfer is complete, the app will be automatically marked as un-orphaned/maintained again.' %}</p>

{% if apps %}
<table class="table table-striped">
<table class="table table-striped transfer-apps">
<tr>
<th>{% trans 'App name' %}</th>
<th>{% trans 'Ownership transfer status' %}</th>
<th>{% trans 'App status' %}</th>
<th>{% trans 'Change ownership transfer status' %}</th>
<th>{% trans 'Change app status' %}</th>
</tr>
{% for app in apps %}
<tr>
<td>{{ app.name }}</td>
<td class="{% if app.ownership_transfer_enabled %}bg-success{% else %}bg-danger{% endif %}">
{% if app.ownership_transfer_enabled %}
{% trans 'Unlocked for transfer' %}
{% trans 'Unlocked' %}
{% else %}
{% trans 'Locked, no transfer possible' %}
{% trans 'Locked' %}
{% endif %}
</td>
<td class="{% if app.is_orphan %}bg-danger{% else %}bg-success{% endif %}">
{% if app.is_orphan %}
{% trans 'Orphaned' %}
{% else %}
{% trans 'Maintained' %}
{% endif %}
</td>
<td>
Expand All @@ -36,6 +46,16 @@ <h1>{% trans "Transfer Apps" %}</h1>
{% endif %}
</form>
</td>
<td>
<form action="{% url 'user:account-orphan-app' pk=app.id %}" method="post">
{% csrf_token %}
{% if app.is_orphan %}
<button class="btn btn-primary btn-block" type="submit">{% trans 'Mark as maintained' %}</button>
{% else %}
<button class="btn btn-primary btn-block" type="submit">{% trans 'Mark as orphaned' %}</button>
{% endif %}
</form>
</td>
</tr>
{% endfor %}
</table>
Expand Down
1 change: 1 addition & 0 deletions nextcloudappstore/user/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
),
re_path(r"^transfer-apps/?$", TransferAppsView.as_view(), name="account-transfer-apps"),
re_path(r"^transfer-apps/(?P<pk>[a-z0-9_]+)/?$", TransferAppsView.as_view(), name="account-transfer-app"),
re_path(r"^orphan-apps/(?P<pk>[a-z0-9_]+)/?$", TransferAppsView.as_view(), name="account-orphan-app"),
re_path(r"^password/?$", PasswordView.as_view(), name="account-password"),
re_path(r"^token/?$", APITokenView.as_view(), name="account-api-token"),
re_path(r"^delete/?$", DeleteAccountView.as_view(), name="account-deletion"),
Expand Down
5 changes: 4 additions & 1 deletion nextcloudappstore/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ class TransferAppsView(LoginRequiredMixin, TemplateView):

def post(self, request, pk):
app = get_object_or_404(App, pk=pk, owner=self.request.user)
app.ownership_transfer_enabled = not app.ownership_transfer_enabled
if "transfer" in request.path:
app.ownership_transfer_enabled = not app.ownership_transfer_enabled
if "orphan" in request.path:
app.is_orphan = not app.is_orphan
app.save()
return redirect(reverse("user:account-transfer-apps"))

Expand Down

0 comments on commit f55c253

Please sign in to comment.