Exemple #1
0
def revert_document(request, slug, ct_id, obj_id, revision):
    doc = get_object(ct_id, obj_id)
    cs = doc.changes.get(revision=revision)
    cs.reapply(request.user)
    m = "you has successfully reverted %s to revision %s" %(cs.content_object, cs.revision)
    request.user.message_set.create(message=m)
    return HttpResponseRedirect(reverse('jaxerdoc_queue_moderation'))
Exemple #2
0
 def set_activiation_key(self):
     from hashlib import sha224
     from jaxerutils.utils import get_object
     if self.action == 'new' and self.moderate == "approval":    
         obj = get_object(self.content_type.pk, self.object_id)
         secure_string = '$sha$%s$%s$%s' % (self.adding_type, self.editor.username, obj.created)
         self.add_key = sha224(secure_string).hexdigest()
         self.save()
     return self.add_key
Exemple #3
0
def show_difference(request, slug, ct_id, obj_id, version):
    obj = get_object(ct_id, obj_id)
    cs = obj.changes.get(revision = version) 
    html = cs.display_change_html()
    if request.is_ajax():
        return HttpResponse(html, mimetype="text/html")
    else:
        return render_to_response('jaxerdoc/queue_difference.html',
                                  {'difference':html},
                                  context_instance=RequestContext(request))
def ajax_document_edit(request, ctid, objid, template_name = None):  
    from jaxerdoc.forms import GenericEditForm
    from jaxerdoc.utils import get_object
    doc = get_object(ctid, objid)
    if request.is_ajax():   
        if request.POST:
            form = GenericEditForm(request.POST, instance = doc)
            if form.is_valid():
                return HttpResponse(simplejson.dumps({'message':"Success!"}),
                                    mimetype = "application/javascript")
        else:
            obj = get_object(ctid, objid)
            form = GenericEditForm(initial = {'editor':request.user.id,
                                            'object_id':objid,
                                            'content_type':ctid,
                                            'content':obj.get_html_content(),
                                            'at_revision':obj.version_number(),
                                            'action':'edit'})
            # the client is expecting an HTML fragment
            return HttpResponse(form.as_ul())
    #we are submitting the form via the html <input> element for simplicity's sake
    else:  
        if request.POST:
            # we don't pass an instance, becase we are creating a QueuedItem, not a new document item(yet)
            form = GenericEditForm(request.POST)
            message = {}
            if form.is_valid():
                form.save()
            else:
                message['class'] = 'error'
                message['message'] = form.errors.keys()[0]
            type = ContentType.objects.get(pk = ctid)
            model = type.model_class()
            obj = model.objects.get(pk = objid)                
            template = "jaxerdoc/%s_detail.html" % type.model
            context = {"%s" % type.model:obj, 'message':message}
            return direct_to_template(request, template, extra_context = context)
    return HttpResponseRedirect(doc.get_absolute_url())
Exemple #5
0
def version_manager(request, ct_id, obj_id):
    obj = get_object(ct_id, obj_id)
    return render_to_response('jaxerdoc/version_manager.html', {'object':obj}, RequestContext(request))