Пример #1
0
def seminar(request, slug):
    c = get_common_context(request)
    seminar = Seminar.get(slug, c['lang'])
    c['seminar'] = seminar
    if request.method == 'POST':
        if request.POST.get('action') == 'comment':
            Seminar.objects.get(slug=slug).add_comment(request.user, 
                            request.POST.get('content'))
            return HttpResponseRedirect('/seminar/%s/' % slug)
    return render_to_response('seminar.html', c, context_instance=RequestContext(request))
Пример #2
0
def search(request):
    c = get_common_context(request)
    if request.method == 'POST':
        q = request.POST.get('q', '')
        if q:
            c['q'] = q
            c['projects'] = Project.search(q, c['lang'])
            c['news'] = Article.search(q, c['lang'])
            c['seminars'] = Seminar.search(q, c['lang'])
            return render_to_response('search.html', c, context_instance=RequestContext(request))
    return HttpResponseRedirect('/')
Пример #3
0
# Create seminar slots for the current year.
from seminars import db
from seminars.models import Seminar
for i in range(10):
    db.session.add(Seminar())
db.session.commit()
Пример #4
0
#!flask/bin/python
from migrate.versioning import api
from seminars.config import (SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
from seminars import app, db
import os.path
with app.app_context():
    db.create_all()

from seminars.models import Seminar

# Find the next seminar time.
import datetime as dt

next_slot = dt.datetime.strptime("Wednesday 12:00 PM", "%A %I:%M %p")
while next_slot < dt.datetime.now():
    next_slot += dt.timedelta(days=7)

for i in range(10):
    db.session.add(Seminar(start_datetime=next_slot))
    next_slot += dt.timedelta(days=7)

db.session.commit()

if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
    api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
                        api.version(SQLALCHEMY_MIGRATE_REPO))
Пример #5
0
def seminars(request):
    c = get_common_context(request)
    c['list'] = Seminar.get_list(c['lang'])
    return render_to_response('seminars.html', c, context_instance=RequestContext(request))