示例#1
0
def content_delete(request, slug, model=None):
  content = _get_content(slug, model)
  content.delete()
  
  msg_key = "success_%s_delete" % model.object_name()
  message = util.get_message(msg_key, 'success_content_delete')
  util.success(request, message)

  return http.HttpResponseRedirect(content.admin_url())
示例#2
0
def contact_form(request):
  contact_form = loader.render_to_string("contact_form.html", {"form":ContactForm()})
  tpl = ContactMessage.get_intro()
  contact_content = tpl.replace('{{form}}', contact_form)
  model=ContactMessage

  if request.method == 'POST':
    form = ContactForm(request.POST)
    if form.is_valid():
      item = form.save()
      msg_key = "success_%s_new" % ContactForm._meta.model.object_name()
      message = util.get_message(msg_key, 'success_content_new')
      util.success(request, message)
      return http.HttpResponseRedirect(ContactMessage.form_url())

  c = template.RequestContext(request, locals())
  return render_to_response('contact_send.html', c)
示例#3
0
  def handle(self):
    comment_form = CommentForm()
    if self.request.method == 'POST':
      params = {'author':self.request.user.username,
                'owner':self.content.owner,
                'content':self.content.uuid,
                'content_type':self.content.app_label}

      comment_form = CommentForm(self.request.POST, extra_params=params)

      if comment_form.is_valid():
        comment_ref = comment_form.save()
        message = util.get_message('success_comment_new')
        util.success(self.request, message)
        return http.HttpResponseRedirect(self.content.url())
    self.update_context({"comment_form":comment_form})

    return self.get_response()
示例#4
0
    def handle(self):
        comment_form = CommentForm()
        if self.request.method == "POST":
            params = {
                "author": self.request.user.username,
                "owner": self.content.owner,
                "content": self.content.uuid,
                "content_type": self.content.app_label,
            }

            comment_form = CommentForm(self.request.POST, extra_params=params)

            if comment_form.is_valid():
                comment_ref = comment_form.save()
                message = util.get_message("success_comment_new")
                util.add_success(self.request, message)
                return http.HttpResponseRedirect(self.content.url())
        self.update_context({"comment_form": comment_form})

        return self.get_response()
示例#5
0
def content_new(request, area='content', model_form=None, tpl='content_new.html', redirect_to=None, extra_context={}, model=None):
  form = model_form()
  if request.method == 'POST':
    form = model_form(request.POST)
    if form.is_valid():
      item = form.save()

      msg_key = "success_%s_new" % model_form._meta.model.object_name()
      message = util.get_message(msg_key, 'success_content_new')
      util.success(request, message)

      if redirect_to is not None:
        if redirect_to == True:
          return http.HttpResponseRedirect(item.url())
        return http.HttpResponseRedirect(redirect_to)
    
  ckeditor = '.ckeditor textarea'
  
  c = template.RequestContext(request, locals())
  c.update(extra_context)
  _flag_as_admin(c)
  return render_to_response(tpl, c)
示例#6
0
def content_edit(request, id, area='content', model=None, model_form=None, tpl='content_edit.html', redirect_to=None, extra_context={}):
  content = _get_content(id, model)

  form = model_form(instance=content)
  if request.method == 'POST':
    form = model_form(request.POST, instance=content)
    if form.is_valid():
      content = form.save()

      msg_key = "success_%s_edit" % model_form._meta.model.object_name()
      message = util.get_message(msg_key, 'success_content_edit')
      util.add_success(request, message)
      
      if redirect_to is not None:
        if redirect_to == True:
          return http.HttpResponseRedirect(content.url())
        return http.HttpResponseRedirect(redirect_to)

  ckeditor = '.ckeditor textarea'
  
  c = template.RequestContext(request, locals())
  c.update(extra_context)
  _flag_as_admin(c)
  return render_to_response(tpl, c)
示例#7
0
 def set_message(self, msg_key, type='success'):
   message = util.get_message(msg_key, 'success_content_new')
   util.add_msg(self.request, type, message)
示例#8
0
 def _flash(request, msg_key, type='success'):
   message = util.get_message(msg_key, 'success_action')
   util.add_msg(request, type, message)
示例#9
0
 def set_message(self, msg_key, type="success"):
     message = util.get_message(msg_key, "success_content_new")
     util.add_msg(self.request, type, message)