Add a maintenance notification kind and make it of the level warning.

This commit is contained in:
Jake Moshenko 2014-06-27 19:18:27 -04:00
parent b47742b011
commit 4e5e8a08de
5 changed files with 69 additions and 9 deletions

View file

@ -2,8 +2,10 @@ import logging
import json
import hashlib
import random
import calendar
from datetime import datetime, timedelta
from email.utils import formatdate
from peewee import (SqliteDatabase, create_model_tables, drop_model_tables,
savepoint_sqlite)
@ -232,6 +234,7 @@ def initialize_database():
NotificationKind.create(name='password_required')
NotificationKind.create(name='over_private_usage')
NotificationKind.create(name='expiring_license')
NotificationKind.create(name='maintenance')
NotificationKind.create(name='test_notification')
@ -289,6 +292,16 @@ def populate_database():
model.create_notification('test_notification', new_user_1, metadata={'some': 'value'})
from_date = datetime.utcnow()
to_date = from_date + timedelta(hours=1)
notification_metadata = {
'from_date': formatdate(calendar.timegm(from_date.utctimetuple())),
'to_date': formatdate(calendar.timegm(to_date.utctimetuple())),
'reason': 'database migration'
}
model.create_notification('maintenance', new_user_1, metadata=notification_metadata)
__generate_repository(new_user_4, 'randomrepo', 'Random repo repository.', False,
[], (4, [], ['latest', 'prod']))