Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
"""Shell access to dribdat.""" | ||
import os | ||
import click | ||
import datetime as dt | ||
from flask.cli import AppGroup | ||
from dateutil.parser import parse | ||
from dribdat.app import init_app | ||
from dribdat.settings import DevConfig, ProdConfig | ||
from dribdat.user.models import Event | ||
from flask.helpers import get_debug_flag | ||
|
||
CONFIG = DevConfig if get_debug_flag() else ProdConfig | ||
|
||
app = init_app(CONFIG) | ||
|
||
event_cli = AppGroup('event') | ||
|
||
|
||
@event_cli.command('start') | ||
@click.argument('name', required=True) | ||
@click.argument('start', required=False) | ||
def event_start(name, start=None): | ||
"""Create a new event.""" | ||
if start is None: | ||
start = dt.datetime.now() + dt.timedelta(days=1) | ||
else: | ||
start = parse(start) | ||
event = Event(name="test", starts_at=start) | ||
event.save() | ||
print("Created event %d" % event.id) | ||
|
||
|
||
app.cli.add_command(event_start()) |