Beispiel #1
0
def setup(request):
    if not request.auth_info.admin:
        raise Http404
    
    from admin.inflect_data import INFLECT_PATTERNS

    for p in INFLECT_PATTERNS:
#        logging.info('p=%s',p)
        inflect = Inflect() 
        inflect.init(owner=request.auth_info.email,gender=p[1],part=p[0],pattern=p[2],proposal=p[3])
        inflect.save()

    return HttpResponse('ok')
Beispiel #2
0
def create(request):

    inflect = Inflect()
    inflect.init(owner=request.auth_info.email)
    if request.method == 'POST':
        form = InflectForm(request.POST, instance=inflect)
        if form.is_valid():
            logging.info('edit inflect before %s'% inflect)
            form.save(commit=False)
            logging.info('edit inflect after %s'% inflect)
            inflect.save()
            return HttpResponseRedirect('..')
    else:
        form = InflectForm(instance=inflect)

    return render_to_response('admin/inflects_create.html', RequestContext(request, {'form':form}))
Beispiel #3
0
def clear_all(request):
    if not request.auth_info.admin:
        raise Http404
    inflect_keys=Inflect.keys_all()
    logging.info('clear all inflect patterns %s'%inflect_keys)
    db.delete(inflect_keys)

    return HttpResponseRedirect('..')
Beispiel #4
0
def init_dicts():
    global DICTS
    logging.info("init dicts")
    inflect_list = Inflect.list()
    DICTS = dict()
    for i in inflect_list:
        dict_key = "%s_%s" % (i.gender, i.part)
        if not dict_key in DICTS:
            DICTS[dict_key] = InflectDict()
        DICTS[dict_key].add(i.pattern, i.proposal)
Beispiel #5
0
def delete(request, inflect_id):


    inflect = Inflect.get_by_id(int(inflect_id))

    if inflect is None:
        raise Http404

    inflect.delete()

    return HttpResponseRedirect('../..')
Beispiel #6
0
def edit(request, inflect_id):

    inflect = Inflect.get_by_id(int(inflect_id))

    if inflect is None:
        raise Http404

    if request.method == 'POST':
        form = InflectForm(request.POST, instance=inflect)
        if form.is_valid():
            logging.info('edit inflect before %s'% inflect)
            form.save(commit=False)
            logging.info('edit inflect after %s'% inflect)
            inflect.save()
            return HttpResponseRedirect('../..')
    else:
        form = InflectForm(instance=inflect)

    return render_to_response('admin/inflects_edit.html', RequestContext(request, {'form':form}))
Beispiel #7
0
def index(request):
    inflect_list=Inflect.list()

    return render_to_response('admin/inflects_index.html', RequestContext(request, { 'inflect_list': inflect_list }))