Étend la recherche ENT et Outlook à un an
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
Some checks are pending
CI - Tests et Syntax / lint-and-test (push) Waiting to run
This commit is contained in:
parent
25934d018d
commit
8233b085de
4 changed files with 60 additions and 10 deletions
|
|
@ -8,6 +8,16 @@ from app_new.extensions import db
|
|||
from app_new.outlook.models import GmaoContext
|
||||
|
||||
gmao_config_bp = Blueprint('gmao_config', __name__, template_folder='templates')
|
||||
LOOKBACK_MAX_HOURS = 24 * 365
|
||||
|
||||
|
||||
def _bounded_int(value, default, minimum=1, maximum=None):
|
||||
try:
|
||||
parsed = int(value)
|
||||
except (TypeError, ValueError):
|
||||
parsed = default
|
||||
parsed = max(minimum, parsed)
|
||||
return min(maximum, parsed) if maximum is not None else parsed
|
||||
|
||||
|
||||
@gmao_config_bp.route('/')
|
||||
|
|
@ -65,7 +75,10 @@ def save():
|
|||
context.auto_interpret_enabled = request.form.get('auto_interpret_enabled') == 'on'
|
||||
context.auto_interpret_interval = max(1, int(request.form.get('auto_interpret_interval', 10)))
|
||||
context.auto_interpret_max_emails = max(1, int(request.form.get('auto_interpret_max_emails', 5)))
|
||||
context.auto_interpret_lookback_hours = max(1, int(request.form.get('auto_interpret_lookback_hours', 24)))
|
||||
context.auto_interpret_lookback_hours = _bounded_int(
|
||||
request.form.get('auto_interpret_lookback_hours'), 24,
|
||||
maximum=LOOKBACK_MAX_HOURS,
|
||||
)
|
||||
|
||||
# Activation de la synchronisation PRONOTE
|
||||
context.pronote_sync_enabled = request.form.get('pronote_sync_enabled') == 'on'
|
||||
|
|
@ -75,7 +88,10 @@ def save():
|
|||
# Activation de la synchronisation Outlook
|
||||
context.outlook_sync_enabled = request.form.get('outlook_sync_enabled') == 'on'
|
||||
context.outlook_sync_interval = max(1, int(request.form.get('outlook_sync_interval', 10)))
|
||||
context.outlook_sync_lookback_hours = max(1, int(request.form.get('outlook_sync_lookback_hours', 24)))
|
||||
context.outlook_sync_lookback_hours = _bounded_int(
|
||||
request.form.get('outlook_sync_lookback_hours'), 24,
|
||||
maximum=LOOKBACK_MAX_HOURS,
|
||||
)
|
||||
|
||||
# Configuration IA
|
||||
from app_new.core.models.settings import AppSettings
|
||||
|
|
|
|||
|
|
@ -249,9 +249,10 @@
|
|||
value="{{ context.auto_interpret_max_emails or 5 }}">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label">Lookback (heures)</label>
|
||||
<input type="number" name="auto_interpret_lookback_hours" class="form-control" min="1" max="168"
|
||||
<label class="form-label">Lookback ENT / interprétation (heures)</label>
|
||||
<input type="number" name="auto_interpret_lookback_hours" class="form-control" min="1" max="8760"
|
||||
value="{{ context.auto_interpret_lookback_hours or 24 }}">
|
||||
<small class="text-muted">Maximum : 8 760 heures (365 jours).</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -306,8 +307,9 @@
|
|||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">Lookback (heures)</label>
|
||||
<input type="number" name="outlook_sync_lookback_hours" class="form-control" min="1" max="168"
|
||||
<input type="number" name="outlook_sync_lookback_hours" class="form-control" min="1" max="8760"
|
||||
value="{{ context.outlook_sync_lookback_hours or 24 }}">
|
||||
<small class="text-muted">Maximum : 8 760 heures (365 jours).</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -415,4 +417,4 @@ function testInterpretation() {
|
|||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -249,9 +249,10 @@
|
|||
value="{{ context.auto_interpret_max_emails or 5 }}">
|
||||
</div>
|
||||
<div class="col-md-4 mb-3">
|
||||
<label class="form-label">Lookback (heures)</label>
|
||||
<input type="number" name="auto_interpret_lookback_hours" class="form-control" min="1" max="168"
|
||||
<label class="form-label">Lookback ENT / interprétation (heures)</label>
|
||||
<input type="number" name="auto_interpret_lookback_hours" class="form-control" min="1" max="8760"
|
||||
value="{{ context.auto_interpret_lookback_hours or 24 }}">
|
||||
<small class="text-muted">Maximum : 8 760 heures (365 jours).</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -306,8 +307,9 @@
|
|||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">Lookback (heures)</label>
|
||||
<input type="number" name="outlook_sync_lookback_hours" class="form-control" min="1" max="168"
|
||||
<input type="number" name="outlook_sync_lookback_hours" class="form-control" min="1" max="8760"
|
||||
value="{{ context.outlook_sync_lookback_hours or 24 }}">
|
||||
<small class="text-muted">Maximum : 8 760 heures (365 jours).</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -415,4 +417,4 @@ function testInterpretation() {
|
|||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
30
tests/integration/test_gmao_config_lookback.py
Normal file
30
tests/integration/test_gmao_config_lookback.py
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
from app_new.extensions import db
|
||||
from app_new.outlook.models import GmaoContext
|
||||
|
||||
|
||||
def test_gmao_config_accepts_one_year_lookback(authenticated_client, app, admin_user):
|
||||
response = authenticated_client.post('/gmao-config/save', data={
|
||||
'auto_interpret_lookback_hours': '8760',
|
||||
'outlook_sync_lookback_hours': '8760',
|
||||
})
|
||||
assert response.status_code == 302
|
||||
with app.app_context():
|
||||
context = GmaoContext.query.filter_by(user_id=admin_user['id']).one()
|
||||
assert context.auto_interpret_lookback_hours == 8760
|
||||
assert context.outlook_sync_lookback_hours == 8760
|
||||
db.session.delete(context)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def test_gmao_config_caps_lookback_at_one_year(authenticated_client, app, admin_user):
|
||||
response = authenticated_client.post('/gmao-config/save', data={
|
||||
'auto_interpret_lookback_hours': '9000',
|
||||
'outlook_sync_lookback_hours': '9000',
|
||||
})
|
||||
assert response.status_code == 302
|
||||
with app.app_context():
|
||||
context = GmaoContext.query.filter_by(user_id=admin_user['id']).one()
|
||||
assert context.auto_interpret_lookback_hours == 8760
|
||||
assert context.outlook_sync_lookback_hours == 8760
|
||||
db.session.delete(context)
|
||||
db.session.commit()
|
||||
Loading…
Reference in a new issue