예제 #1
0
def edit_profile_photo(request):
    """ """
    tab = 'photo'
    user = request.user
    profile = user
    if request.method == 'POST':
        form = ProfilePhotoForm(request.POST, request.FILES)
        if form.is_valid():
            photo = handle_uploaded_file(request.FILES['avatarpic'], profile.get_fullname())
            profile.photo = photo
            profile.save()

    else:
        form = ProfilePhotoForm()
    return render(request, 'profile/edit_photo.html', locals())
예제 #2
0
def add_game(request):
    """ """
    user = request.user
    if request.method == 'POST':
        gameform = GameCatalogForm(request.POST)
        if gameform.is_valid():
            jokoa = gameform.save(commit=False)
            jokoa.slug = slugify(jokoa.izena)[:50]
            jokoa.publikoa_da = False
            if request.FILES.get('logoa', ''):
                photo = handle_uploaded_file(request.FILES['logoa'], user.getFullName())
                jokoa.logoa = photo
            jokoa.save()
            return render(request, 'profile/game_sent.html', locals())
    else:
        gameform = GameCatalogForm()
    return render(request, 'profile/add_game.html', locals())
예제 #3
0
def add_article(request):
    """ """
    user = request.user
    if request.method == 'POST':
        articleform = ArticleForm(request.POST)
        if articleform.is_valid():
            berria = articleform.save(commit=False)
            berria.slug = slugify(berria.izenburua)
            berria.erabiltzailea = user
            berria.publikoa_da = True
            if request.FILES.get('argazkia',''):
                photo = handle_uploaded_file(request.FILES['argazkia'], user.getFullName())
                berria.argazkia = photo
            berria.save()
            articleform.save_m2m()
            return render_to_response('profile/article_sent.html', locals(), context_instance=RequestContext(request))
    else:
        articleform = ArticleForm()
    return render_to_response('profile/add_article.html', locals(), context_instance=RequestContext(request))
예제 #4
0
def add_article(request):
    """ """
    user = request.user
    if request.method == 'POST':
        articleform = ArticleForm(request.POST)
        if articleform.is_valid():
            berria = articleform.save(commit=False)
            berria.slug = slugify(berria.izenburua)[:50]
            berria.erabiltzailea = user
            berria.publikoa_da = True
            if request.FILES.get('argazkia', ''):
                photo = handle_uploaded_file(request.FILES['argazkia'], user.getFullName())
                berria.argazkia = photo
            berria.save()
            articleform.save_m2m()
            return render(request, 'profile/article_sent.html', locals())
    else:
        articleform = ArticleForm()
    return render(request, 'profile/add_article.html', locals())
예제 #5
0
def add_gameplay(request):
    """ """
    user = request.user
    if request.method == 'POST':
        gameplayform = GamePlayForm(request.POST)
        if gameplayform.is_valid():
            if not request.FILES.get('argazkia',''):
                gameplayform._errors["argazkia"] = ErrorList([u"Argazkia jartzea derrigorrezkoa da. Mesedez, jarri argazki polit bat!"])
            else:
                gp = gameplayform.save(commit=False)
                gp.slug = slugify(gp.izenburua)
                gp.erabiltzailea = user
                gp.publikoa_da = True
                gp.argazkia = handle_uploaded_file(request.FILES['argazkia'], user.getFullName())
                gp.save()
                gameplayform.save_m2m()
                return render_to_response('profile/gameplay_sent.html', locals(), context_instance=RequestContext(request))
    else:
        gameplayform = GamePlayForm()
    return render_to_response('profile/add_gameplay.html', locals(), context_instance=RequestContext(request))
예제 #6
0
def add_gameplay(request):
    """ """
    user = request.user
    if request.method == 'POST':
        gameplayform = GamePlayForm(request.POST)
        if gameplayform.is_valid():
            if not request.FILES.get('argazkia', ''):
                gameplayform._errors["argazkia"] = ErrorList(
                    [u"Argazkia jartzea derrigorrezkoa da. Mesedez, jarri argazki polit bat!"])
            else:
                gp = gameplayform.save(commit=False)
                gp.slug = slugify(gp.izenburua)[:50]
                gp.erabiltzailea = user
                gp.publikoa_da = True
                gp.argazkia = handle_uploaded_file(request.FILES['argazkia'], user.getFullName())
                gp.save()
                gameplayform.save_m2m()
                return render(request, 'profile/gameplay_sent.html', locals())
    else:
        gameplayform = GamePlayForm()
    return render(request, 'profile/add_gameplay.html', locals())