Example #1
0
    def post(self, request):
        form = ArticleForm(request.POST)
        if not form.is_valid():
            return render(request, 'articles/article-form.html',
                    {'form': form, 'post_url': reverse('articles:add')})
        article = form.save(commit=False)
        article.editor = request.user
        article.create_ip = get_client_ip(request)

        re.sub(r'./imageTemp', "http://7xrrsw.com1.z0.glb.clouddn.com/stucampus-for-jiangxia", article.content)
        img_id = re.split(',', article.img_list)
        id_num = len(img_id)
        i = 0
        while(i < id_num):
            temp_obj1 = re.compile('<img id="' + id_num[i] + '.*?>')
            temp_obj2 = re.compile('value1=".*?"')
            temp_obj2b = re.compile('value2=".*?"')
            temp_obj3 = re.compile('[\d]+')
            temp_obj5 = re.compile('">')

            temp_str1 = temp_obj1.search(article.content)
            temp_str1b = temp_str1
            temp_str2 = temp_obj2.search(temp_str1)
            temp_str2b = temp_obj2b.search(temp_str1)
            temp_val1 = temp_obj3.search(temp_str2)
            temp_val2 = temp_obj3.search(temp_str2b)
            temp_str1 = re.sub(temp_obj5, '?imageView/2/w/' + temp_val1 + '/h/' + temp_val2 + '">', temp_str1)
            article.content = re.sub(temp_str1b, temp_str1, article.content)
            
        article.save()
        return HttpResponseRedirect(reverse('articles:manage'))

        execfile('./getImage.py')
Example #2
0
 def post(self, request):
     form = ArticleForm(request.POST)
     if not form.is_valid():
         return render(request, 'articles/article-form.html',
                 {'form': form, 'post_url': reverse('articles:add')})
     article = form.save(commit=False)
     article.editor = request.user
     article.create_ip = get_client_ip(request)
     article.save()
     return HttpResponseRedirect(reverse('articles:manage'))
Example #3
0
 def post(self, request):
     article_id = request.GET.get('id')
     article = get_object_or_404(Article, pk=article_id)
     form = ArticleForm(request.POST, instance=article)
     if not form.is_valid():
         return render(request, 'articles/article-form.html',
             {'form': form, 'article_id': article_id,
              'post_url': reverse('articles:modify')})
     form.save()
     return HttpResponseRedirect(reverse('articles:manage'))
Example #4
0
 def post(self, request):
     form = ArticleForm(request.POST,request.FILES )
     if not form.is_valid():
         return render(request, 'articles/article-form.html',
                 {'form': form, 'post_url': reverse('articles:add')})
     article = form.save(commit=False)
     article.editor = request.user
     article.create_ip = get_client_ip(request)
     article.save()
     return HttpResponseRedirect(reverse('articles:manage'))
Example #5
0
 def post(self, request):
     article_id = request.GET.get('id')
     article = get_object_or_404(Article, pk=article_id)
     form = ArticleForm(request.POST,request.FILES,instance=article)
     page = request.GET.get('page')
     if not form.is_valid():
         return render(request, 'articles/article-form.html',
             {'form': form, 'article_id': article_id,
              'post_url': reverse('articles:modify')})
     form.save()
     return HttpResponseRedirect(reverse('articles:manage')+'?page='+page)
Example #6
0
 def get(self, request):
     article_id = request.GET.get('id')
     article = get_object_or_404(Article, pk=article_id)
     form = ArticleForm(instance=article)
     page = request.GET.get('page')
     return render(request, 'articles/article-form.html',
             {'form': form, 'article_id': article_id, 'page': page,
              'post_url': reverse('articles:modify')})
Example #7
0
 def get(self, request):
     form = ArticleForm()
     return render(request, 'articles/article-form.html', {
         'form': form,
         'post_url': reverse('articles:add')
     })