示例#1
0
def addPublicSub(request):
    subjecto = globar
    if request.is_ajax():
        signal = request.POST['signal']
#        print("ok");
#        print("this is the signal:" + signal);
    
        if signal == 'sub':
            current_user = request.user
#             request.session()
            #print()

#            print("this is the subject:",subjecto);
            dbRoutine.link_subject(current_user, subjecto)

    return render_to_response('collectionadded.html')
示例#2
0
def new_card(request):
    
    json_dict = json.loads(request.body.decode('utf-8'))
    
    subject = json_dict['subject']
    question = json_dict['question']
    answer = json_dict['answer']
    
    subject.lower().title()
    card = dbRoutine.create_fc(subject, question, answer)

    current_user = request.user
    dbUser = dbRoutine.retrieve_account_no_password(current_user)
    dbRoutine.link_card(dbUser.getName(), card)
    dbRoutine.link_subject(dbUser.getName(), subject)
    
    return JsonResponse({'new_card':'success'})
示例#3
0
def index(request):
    sub=""
    que=""
    ans=""
    form = CreateForm(request.POST or None)
    
    if form.is_valid():
        sub = form.cleaned_data['subject']
        que = form.cleaned_data['question']
        ans = form.cleaned_data['answer']
        
        sub.lower();
        card = dbRoutine.create_fc(sub, que, ans)
    
        current_user = request.user
        dbUser = dbRoutine.retrieve_account_no_password(current_user)
        dbRoutine.link_card(dbUser.getName(), card)
        dbRoutine.link_subject(dbUser.getName(), sub)
        
        cards = dbUser.getCards()
        
        print (cards.count())
    
        return HttpResponseRedirect('createMore/')
    #===========================================================================
    # allSubjects = Subject.objects.all();
    # 
    # subjectData = {
    #     "sub_detail" : allSubjects
    # }
    #===========================================================================
    
    if request.user.is_authenticated():
        current_user = request.user
        logged_in = 1
    else:
        current_user = request.user
        logged_in = 0
    
    context={
        "form": form,
        "current_user": current_user,
        "logged_in": logged_in
    }   
    
    return render(request, 'create.html', context)