コード例 #1
0
ファイル: views.py プロジェクト: vollov/sm
def create_store(request):
    logger.debug('calling store.views.create_store()')
    if request.method == 'POST':
        store_form = StoreForm(data=request.POST)
        if store_form.is_valid():
            store = store_form.save(commit=False)
            store.owner = request.user
            print 'user = {0}'.format(vars(request.user))
            store.save()
            return owner_profile(request)
        else:
            print store_form.errors
            return HttpResponse("Create store is failed.")
    else:
        # for visitor, generate empty menu
        
        menu = MenuService.new_user_menu(request.user)
        
        store_form = StoreForm()
        
    requestContext = RequestContext(request, {'menu':menu,
                                              'store_form': store_form, 
                                              'page_title': 'Create store'} )

    # Render the template depending on the context.
    return render_to_response('new.html', requestContext)
コード例 #2
0
ファイル: views.py プロジェクト: vollov/sm
def profile(request):
    logger.debug('calling store.views.profile()')
    
    menu = MenuService.new_user_menu(request.user)
    context = {
        'menu':menu,
        'page_title': 'User profile',
        'user': request.user,
    }
    return render_to_response('profile.html', context)
コード例 #3
0
ファイル: views.py プロジェクト: vollov/sm
def store_list(request, user_id):
    """
    Verify user has the access to enlist store.
    """
    logger.debug('calling store.views.store_list()')
    user_name = request.user.username
    
    menu = MenuService.new_user_menu(request.user)
    context = {
        'menu':menu,
        'page_title': 'Profile',
        'user_name': user_name,
    }
    return render_to_response('profile.html', context)