mirror of
https://github.com/YunoHost/tartiflette.git
synced 2024-09-03 20:06:08 +02:00
Simplify app list management, we don't have official vs. community anymore
This commit is contained in:
parent
75f5042eb7
commit
8c627522b2
6 changed files with 12 additions and 62 deletions
|
@ -1,7 +1,7 @@
|
|||
from datetime import datetime
|
||||
from flask import render_template, make_response, Blueprint
|
||||
from .models.pr import PullRequest
|
||||
from .models.applists import App
|
||||
from .models.appcatalog import App
|
||||
from .models.appci import AppCI, AppCIBranch
|
||||
from .models.unlistedapps import UnlistedApp
|
||||
from .settings import SITE_ROOT
|
||||
|
@ -189,10 +189,9 @@ def app_maintainer_dash(maintainer=None):
|
|||
if isinstance(app.public_level, str):
|
||||
app.public_level = -1
|
||||
|
||||
if app.maintained and app.state in ["working", "official"]:
|
||||
if app.maintained and app.state == "working":
|
||||
maintainers.update(app.maintainers)
|
||||
|
||||
|
||||
maintainers = sorted(maintainers, key=lambda m: m.lower())
|
||||
apps = sorted(apps, key=lambda app: app.name.lower())
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import re
|
||||
import os
|
||||
import time
|
||||
import json
|
||||
import requests
|
||||
|
@ -8,35 +7,13 @@ import datetime
|
|||
from .. import db
|
||||
|
||||
|
||||
class AppList(db.Model):
|
||||
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
name = db.Column(db.String(64), unique=True, nullable=False)
|
||||
url = db.Column(db.String(128), nullable=False)
|
||||
state_for_ci = db.Column(db.String(32), nullable=False)
|
||||
|
||||
def __repr__(self):
|
||||
return '<AppList %r>' % self.name
|
||||
|
||||
def init():
|
||||
yield AppList(name='official',
|
||||
url="https://app.yunohost.org/official.json",
|
||||
state_for_ci='validated')
|
||||
yield AppList(name='community',
|
||||
url="https://app.yunohost.org/community.json",
|
||||
state_for_ci='working')
|
||||
class AppCatalog(db.Model):
|
||||
|
||||
def update():
|
||||
|
||||
applists = AppList.query.all()
|
||||
for applist in applists:
|
||||
applist.update_list()
|
||||
|
||||
def update_list(self):
|
||||
|
||||
g = Github()
|
||||
|
||||
raw_apps = json.loads(requests.get(self.url).text)
|
||||
raw_apps = json.loads(requests.get("https://app.yunohost.org/default/v2/apps.json").text)
|
||||
|
||||
for name in sorted(raw_apps.keys()):
|
||||
|
||||
|
@ -52,7 +29,6 @@ class AppList(db.Model):
|
|||
print("Adding new app {}".format(name))
|
||||
known_app = App(name=name,
|
||||
repo=app["url"],
|
||||
list=self,
|
||||
public_commit=app["git"]["revision"])
|
||||
db.session.add(known_app)
|
||||
else:
|
||||
|
@ -76,7 +52,6 @@ class AppList(db.Model):
|
|||
elif isinstance(known_app.maintained, str):
|
||||
known_app.maintained = True
|
||||
known_app.state = app["state"]
|
||||
known_app.ci_enabled = app["state"] == self.state_for_ci
|
||||
known_app.public_level = app.get("level", None)
|
||||
|
||||
if "github" in known_app.repo:
|
||||
|
@ -112,12 +87,8 @@ class App(db.Model):
|
|||
maintainers = db.Column(db.PickleType)
|
||||
maintained = db.Column(db.Boolean, nullable=False)
|
||||
state = db.Column(db.String(64), nullable=False)
|
||||
ci_enabled = db.Column(db.Boolean, nullable=False)
|
||||
public_level = db.Column(db.Integer, default=-1, nullable=True)
|
||||
|
||||
list = db.relationship(AppList, backref='apps', lazy=True, uselist=False)
|
||||
list_id = db.Column(db.ForeignKey(AppList.id))
|
||||
|
||||
# 'Status info' stuff
|
||||
public_commit = db.Column(db.String(64), nullable=False)
|
||||
master_commit = db.Column(db.String(64), nullable=False)
|
|
@ -3,7 +3,7 @@ import requests
|
|||
import datetime
|
||||
|
||||
from .. import db
|
||||
from app.models.applists import App
|
||||
from app.models.appcatalog import App
|
||||
|
||||
class AppCIBranch(db.Model):
|
||||
|
||||
|
@ -52,7 +52,7 @@ class AppCIBranch(db.Model):
|
|||
|
||||
def most_recent_tests_per_app(self):
|
||||
|
||||
apps = App.query.filter_by(ci_enabled=True).all()
|
||||
apps = App.query.filter_by(state="working").all()
|
||||
most_recent_tests = AppCIResult.query \
|
||||
.filter_by(branch = self) \
|
||||
.order_by(AppCIResult.date.desc()) \
|
||||
|
|
|
@ -10,7 +10,7 @@ appdir = os.path.abspath(currentdir + "../../../../")
|
|||
sys.path.insert(0, appdir)
|
||||
|
||||
from app import db, create_app
|
||||
from app.models.applists import App
|
||||
from app.models.appcatalog import App
|
||||
app_ = create_app()
|
||||
|
||||
def _time_points_until_today():
|
||||
|
|
|
@ -64,26 +64,6 @@
|
|||
<div class="col-sm-4 offset-sm-4">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{% if app.public_commit == 'HEAD' %}
|
||||
<p class="card-text text-success">
|
||||
<span class="oi oi-task" aria-hidden="true"></span>
|
||||
This app points to HEAD in {{ app.list.name }}.json !
|
||||
</p>
|
||||
{% elif app.public_commit == app.master_commit %}
|
||||
<p class="card-text text-success">
|
||||
<span class="oi oi-task" aria-hidden="true"></span>
|
||||
Master commit is up to date with {{ app.list.name }}.json !
|
||||
</p>
|
||||
{% else %}
|
||||
{% if app.public_vs_master_time_diff > 60 %}
|
||||
<p class="card-text text-danger">
|
||||
{% else %}
|
||||
<p class="card-text text-warning">
|
||||
{% endif %}
|
||||
<span class="oi oi-warning" aria-hidden="true"></span>
|
||||
Commit is not up to date on {{ app.list.name }}.json !
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
{% if app.testing_pr %}
|
||||
<p class="card-text text-info">
|
||||
|
|
10
manage.py
10
manage.py
|
@ -21,13 +21,13 @@ class Update(Command):
|
|||
|
||||
def run(self, args=None):
|
||||
|
||||
valid_what = ["applists", "appci", "pr", "appobservatory"]
|
||||
valid_what = ["catalog", "appci", "pr", "appobservatory"]
|
||||
what = args[0] if args else None
|
||||
assert what in valid_what, "Please specify what to update among %s" % ', '.join(valid_what)
|
||||
|
||||
if what == "applists":
|
||||
from app.models.applists import AppList
|
||||
AppList.update()
|
||||
if what == "catalog":
|
||||
from app.models.appcatalog import AppCatalog
|
||||
AppCatalog.update()
|
||||
elif what == "appci":
|
||||
from app.models.appci import AppCI
|
||||
AppCI.update()
|
||||
|
@ -49,7 +49,7 @@ class Nuke(Command):
|
|||
|
||||
def run(self):
|
||||
|
||||
import app.models.applists
|
||||
import app.models.appcatalog
|
||||
import app.models.appci
|
||||
import app.models.pr
|
||||
import app.models.unlistedapps
|
||||
|
|
Loading…
Reference in a new issue