Ejemplo n.º 1
0
def edit_screen_shot(request, theme_slug, type):
    app_name = 'imager'
    app_page = 'create_theme'
    page_name = 'Upload Screenshot'
    
    is_before = (type == 'before')
    
    theme = Theme.get_or_none(slug=theme_slug)
    twitter_user = view_utils.current_twitter_user(request)
    if not twitter_user == theme.author:
        return HttpResponseRedirect(reverse('edit_some_theme'))
    if is_before:
        screenshot = theme.before_screenshot
        screenshot_field = 'before_screenshot'
    else:
        screenshot = theme.after_screenshot
        screenshot_field = 'after_screenshot'
    
    ThemeForm = forms.get_form(Theme, forms.EDIT_TYPE, fields=(screenshot_field,))
    if request.POST or request.FILES:
        form = ThemeForm(request.POST, request.FILES, instance=theme)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('edit_theme', args=(theme.slug,)))
    else:
        form = ThemeForm(instance=theme)
    
    return render_response(request, 'imager/edit/screen_shot.html', locals())
Ejemplo n.º 2
0
def edit_image(request, theme_slug, code):
    app_name = 'imager'
    app_page = 'edit_theme'
    page_name = 'Upload Image'
    
    theme = Theme.get_or_none(slug=theme_slug)
    twitter_user = view_utils.current_twitter_user(request)

    if not twitter_user == theme.author:
        return HttpResponseRedirect(reverse('edit_some_theme'))

    code = Code.get_or_none(code=code)
    
    image = theme.image_or_redirect(code)
    if isinstance(image, WeatherImage):
        w = image
    else: 
        w = WeatherImage(theme=theme, code=code)
    
    FormKlass = forms.get_form(WeatherImage, forms.EDIT_TYPE)
    if request.POST or request.FILES:
        form = FormKlass(request.POST, request.FILES, instance=w)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('edit_theme', args=(theme.slug,)))
            '''
            try:
                w = form.save()
                return HttpResponseRedirect(reverse('edit_theme', args=(theme.slug,)))
            except:
                pass#WeatherImage.add(code=code, theme=theme, image=
            '''
            
            #import Image
            #uploaded = Image.open(w.image.path)
            #logo_name = Image.open(settings.MEDIA_ROOT+'twitter/imager/img/weatherizer_logo_name.png')
            #uploaded.paste(logo_name, (0,0), logo_name)
            #uploaded.save(w.image.path)
            
    else:
        form = FormKlass(instance=w)
    return render_response(request, 'imager/edit_image.html', locals())
Ejemplo n.º 3
0
def edit_author_comments(request, theme_slug):
    app_name = 'imager'
    app_page = 'create_theme'
    page_name = 'Edit Theme'
    
    theme = Theme.get_or_none(slug=theme_slug)
    twitter_user = view_utils.current_twitter_user(request)
    if not twitter_user == theme.author:
        return HttpResponseRedirect(reverse('edit_some_theme'))
    
    ThemeForm = forms.get_form(Theme, forms.EDIT_TYPE, fields=('author_comments',))
    if request.POST:
        form = ThemeForm(request.POST, instance=theme)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('edit_theme', args=(theme.slug,)))
    else:
        form = ThemeForm(instance=theme)
    
    return render_response(request, 'imager/edit/author_comments.html', locals())