mirror of
https://github.com/spiral-project/ihatemoney.git
synced 2025-05-05 20:51:49 +02:00
Compare commits
3 commits
9af0bacaf2
...
9b8adc31d7
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9b8adc31d7 | ||
![]() |
cf77b4c346 | ||
![]() |
edd453c285 |
40 changed files with 159 additions and 38 deletions
|
@ -4,6 +4,7 @@ import getpass
|
|||
import os
|
||||
import random
|
||||
import sys
|
||||
import datetime
|
||||
|
||||
import click
|
||||
from flask.cli import FlaskGroup
|
||||
|
@ -93,5 +94,97 @@ def delete_project(project_name):
|
|||
db.session.commit()
|
||||
|
||||
|
||||
@cli.command()
|
||||
@click.option(
|
||||
"-l", "--bills_low", type=int, required=False, help="The minimum number of bills"
|
||||
)
|
||||
@click.option(
|
||||
"-h", "--bills_high", type=int, required=False, help="Maximum number of bills"
|
||||
)
|
||||
@click.option(
|
||||
"-d",
|
||||
"--num_days",
|
||||
required=False,
|
||||
type=int,
|
||||
help="Max number of days you want the oldest result to be",
|
||||
)
|
||||
@click.option(
|
||||
"-e",
|
||||
"--emails",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Returns emails rather than project names",
|
||||
)
|
||||
@click.option(
|
||||
"-n",
|
||||
"--names",
|
||||
is_flag=True,
|
||||
default=False,
|
||||
help="Returns list of names of projects",
|
||||
)
|
||||
def get_all_projects(
|
||||
bills_low=None, bills_high=None, num_days=None, emails=None, names=None
|
||||
):
|
||||
"""Displays the number of projects. Options exist to specify for \
|
||||
projects within the bounds of the specified number of bills (inclusive) and/or less than x days old. """
|
||||
if bills_low and bills_high:
|
||||
|
||||
# Make sure low < high
|
||||
if bills_high < bills_low:
|
||||
temp = bills_high
|
||||
bills_high = bills_low
|
||||
bills_low = temp
|
||||
|
||||
if num_days:
|
||||
projects = [
|
||||
pr
|
||||
for pr in Project.query.all()
|
||||
if pr.get_bills().count() >= bills_low
|
||||
and pr.get_bills().count() <= bills_high
|
||||
and pr.get_bills()[0].date
|
||||
> datetime.date.today() - datetime.timedelta(days=num_days)
|
||||
]
|
||||
else:
|
||||
projects = [
|
||||
pr
|
||||
for pr in Project.query.all()
|
||||
if pr.get_bills().count() >= bills_low
|
||||
and pr.get_bills().count() <= bills_high
|
||||
]
|
||||
click.echo(len(projects))
|
||||
if emails:
|
||||
list_emails = ", ".join(set([pr.contact_email for pr in projects]))
|
||||
click.echo(list_emails)
|
||||
if names:
|
||||
proj_names = [pr.name for pr in projects]
|
||||
click.echo(proj_names)
|
||||
|
||||
elif (bills_low and bills_high == None) or (bills_low == None and bills_high):
|
||||
click.secho(
|
||||
f"Invalid number of bounds specified. Please include both a \
|
||||
low and high bound by using (-l or --low) and (-h or --high)",
|
||||
fg="red",
|
||||
)
|
||||
|
||||
else:
|
||||
if num_days:
|
||||
projects = [
|
||||
pr
|
||||
for pr in Project.query.all()
|
||||
if pr.get_bills()[0].date
|
||||
> datetime.date.today() - datetime.timedelta(days=num_days)
|
||||
]
|
||||
else:
|
||||
projects = Project.query.all()
|
||||
|
||||
click.echo(len(projects))
|
||||
if emails:
|
||||
list_emails = ", ".join(set([pr.contact_email for pr in projects]))
|
||||
click.echo(list_emails)
|
||||
if names:
|
||||
proj_names = [pr.name for pr in projects]
|
||||
click.echo(proj_names)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
cli()
|
||||
|
|
|
@ -759,7 +759,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -168,7 +168,7 @@
|
|||
<i class="icon book">{{ static_include("images/book.svg") | safe }}</i>
|
||||
</a>
|
||||
{% if g.show_admin_dashboard_link %}
|
||||
<a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administation Dashboard') }}" href="{{ url_for('main.dashboard') }}">
|
||||
<a target="_blank" rel="noopener" data-toggle="tooltip" data-placement="top" title="{{ _('Administration Dashboard') }}" href="{{ url_for('main.dashboard') }}">
|
||||
<i class="icon admin">{{ static_include("images/cog.svg") | safe }}</i>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
|
|
@ -105,6 +105,34 @@ class TestCommand(BaseTestCase):
|
|||
|
||||
assert len(models.Project.query.all()) == 0
|
||||
|
||||
def test_get_all_projects_basic(self):
|
||||
self.create_project("proj1")
|
||||
self.create_project("proj2")
|
||||
self.create_project("proj3")
|
||||
self.create_project("proj4")
|
||||
|
||||
runner = self.app.test_cli_runner()
|
||||
result = runner.invoke(get_all_projects)
|
||||
self.assertEqual(result, 4)
|
||||
|
||||
def test_get_proj_emails(self):
|
||||
self.create_project("test")
|
||||
runner = self.app.test_cli_runner()
|
||||
result = runner.invoke(get_all_projects(emails = True))
|
||||
self.assertEqual(result, "1 \n demo@notmyidea.org")
|
||||
|
||||
def test_get_proj_names(self):
|
||||
self.create_project("test")
|
||||
runner = self.app.test_cli_runner()
|
||||
result = runner.invoke(get_all_projects(days = 0))
|
||||
self.assertEqual(result, 1)
|
||||
|
||||
def test_get_proj_days(self):
|
||||
self.create_project("test")
|
||||
runner = self.app.test_cli_runner()
|
||||
result = runner.invoke(get_all_projects(low = 1, high =1))
|
||||
self.assertEqual(result, 1)
|
||||
|
||||
|
||||
class TestModels(IhatemoneyTestCase):
|
||||
def test_weighted_bills(self):
|
||||
|
|
|
@ -782,7 +782,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -785,7 +785,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -826,7 +826,7 @@ msgstr "Aplicació mòbil"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentació"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panell d'administració"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -800,7 +800,7 @@ msgstr "Mobilní aplikace"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentace"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Správcovský panel"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -824,7 +824,7 @@ msgstr "Handy-Applikation"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Dashboard Administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -811,7 +811,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -821,7 +821,7 @@ msgstr "Poŝaparata programo"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentaro"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administra panelo"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -818,7 +818,7 @@ msgstr "Aplicación móvil"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentación"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panel de administración"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -815,7 +815,7 @@ msgstr "Aplicación móvil"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentación"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panel de administración"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -782,7 +782,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -824,7 +824,7 @@ msgstr "Application mobile"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panneau d'administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -788,7 +788,7 @@ msgstr "יישום לנייד"
|
|||
msgid "Documentation"
|
||||
msgstr "דוקומנטציה"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -829,7 +829,7 @@ msgstr "मोबाइल एप्लीकेशन"
|
|||
msgid "Documentation"
|
||||
msgstr "प्रलेखन"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "व्यवस्थापन डैशबोर्ड"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -817,7 +817,7 @@ msgstr "Mobil alkalmazás"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentáció"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Adminisztrátori vezérlőpult"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -812,7 +812,7 @@ msgstr "Aplikasi Gawai"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentasi"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Dasbor Administrasi"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -817,7 +817,7 @@ msgstr "Applicazione mobile"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentazione"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Cruscotto Amministrazione"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -797,7 +797,7 @@ msgstr "携帯アプリ"
|
|||
msgid "Documentation"
|
||||
msgstr "書類"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "管理ダッシュボード"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -793,7 +793,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -793,7 +793,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -855,7 +855,7 @@ msgstr "Mobilprogram"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentasjon"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administrasjonsoversiktspanel"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -814,7 +814,7 @@ msgstr "Mobiele app"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentatie"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Administratie-overzicht"
|
||||
|
||||
#, fuzzy
|
||||
|
|
|
@ -777,7 +777,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr "Documentacion"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Panèl d’administracion"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -812,7 +812,7 @@ msgstr "Aplikacja mobilna"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentacja"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Kokpit administracyjny"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -823,7 +823,7 @@ msgstr "Aplicação Mobile"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentação"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Painel de Administração"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -809,7 +809,7 @@ msgstr "Aplicativo"
|
|||
msgid "Documentation"
|
||||
msgstr "Documentação"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Painel de Administração"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -816,7 +816,7 @@ msgstr "Мобильное приложение"
|
|||
msgid "Documentation"
|
||||
msgstr "Документация"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Панель инструментов администратора"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -783,7 +783,7 @@ msgstr "Mobilna Aplikacija"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentacija"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -818,7 +818,7 @@ msgstr "Mobilapplikation"
|
|||
msgid "Documentation"
|
||||
msgstr "Dokumentation"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Översiktspanel för administration"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -809,7 +809,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -817,7 +817,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -778,7 +778,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -811,7 +811,7 @@ msgstr "Telefon Uygulaması"
|
|||
msgid "Documentation"
|
||||
msgstr "Belgelendirme"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "Yönetici Gösterge Paneli"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -791,7 +791,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -776,7 +776,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -775,7 +775,7 @@ msgstr ""
|
|||
msgid "Documentation"
|
||||
msgstr ""
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr ""
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
|
@ -779,7 +779,7 @@ msgstr "手机软件"
|
|||
msgid "Documentation"
|
||||
msgstr "文件"
|
||||
|
||||
msgid "Administation Dashboard"
|
||||
msgid "Administration Dashboard"
|
||||
msgstr "管理面板"
|
||||
|
||||
msgid "Legal information"
|
||||
|
|
Loading…
Reference in a new issue