Ejemplo n.º 1
0
 def render(self,  context):
     link_id = resolve_variable(self.link_id, context, self.link_id)
     row_id = resolve_variable(self.row_id, context, self.row_id)
     
     script = """<script type='text/javascript'>$("#%s").bind("click", function() {$.disable_update("%s", "%s"); return false;});</script>""" % \
             (link_id, link_id, row_id)
     return "\n" + script + "\n"
Ejemplo n.º 2
0
 def render(self,  context):
     link_id = resolve_variable(self.link_id, context, self.link_id)
     data_id = resolve_variable(self.data_id, context, self.data_id)
     content_type = resolve_variable(self.content_type, context, self.content_type)
     object_id = resolve_variable(self.object_id, context, self.object_id)
     
     script = """<script type='text/javascript'>$("#%s").bind("click", function() {$.update_data_call("%s", "%s", "%s"); return false;});</script>""" % \
             (link_id, data_id, content_type, object_id)
     return "\n" + script + "\n"
Ejemplo n.º 3
0
 def render(self,  context):
     cl = resolve_variable(self.cl, context, self.cl)
     mode = resolve_variable(self.mode, context, self.mode)
     
     results_context = result_list(cl)
     if mode == 'form/js':
         results_context['ajax'] = False
     else:
         results_context['ajax'] = True
     return render_to_string("django_relatedcontent/select_change_list_results.html", results_context, context)
Ejemplo n.º 4
0
 def render(self,  context):
     data_id = resolve_variable(self.data_id, context, self.data_id)
     content_type = resolve_variable(self.content_type, context, self.content_type)
     object_id = resolve_variable(self.object_id, context, self.object_id)
     row_id = resolve_variable(self.row_id, context, self.row_id)
     link_id = resolve_variable(self.link_id, context, self.link_id)
     
     script = """<script type='text/javascript'>$.check_related_item("%s", "%s", "%s", "%s", "%s");</script>""" % \
             (data_id, content_type, object_id, row_id, link_id)
     return "\n" + script + "\n"
Ejemplo n.º 5
0
 def render(self,  context):
     values = {}
     link_id = values['link_id'] = resolve_variable(self.link_id, context, self.link_id)
     target_id = values['target_id'] = resolve_variable(self.target_id, context, self.target_id)
     ajax_url = values['ajax_url'] = resolve_variable(self.ajax_url, context, self.ajax_url)
     base_content_type = values['base_content_type'] = resolve_variable(self.base_content_type, context, self.base_content_type)
     selectable_content_type = values['selectable_content_type'] = resolve_variable(self.selectable_content_type, context, self.selectable_content_type)
     base_object_id = values['base_object_id'] = resolve_variable(self.base_object_id, context, self.base_object_id)
     selectable_object_id = values['selectable_object_id'] = resolve_variable(self.selectable_object_id, context, self.selectable_object_id)
     data_id = values['data_id'] = resolve_variable(self.data_id, context, self.data_id)
     usage = values['usage'] = resolve_variable(self.usage, context, self.usage)
     
     script = """<script type='text/javascript'>$("#%(link_id)s").bind("click", 
                     function(e) {$.update_target_call("%(target_id)s", "%(data_id)s", "%(ajax_url)s", 
                                     "%(base_content_type)s", "%(base_object_id)s",
                                     "%(selectable_content_type)s", "%(selectable_object_id)s", "%(usage)s"); 
                 return false;});</script>""" % \
             values
     return "\n" + script + "\n"
Ejemplo n.º 6
0
 def render(self,  context):
     values = {}
     data_id = values['data_id'] = resolve_variable(self.data_id, context, self.data_id)
     target_id = values['target_id'] = resolve_variable(self.target_id, context, self.target_id)
     base_content_type = values['base_content_type'] = resolve_variable(self.base_content_type, context, self.base_content_type)
     selectable_content_type = values['selectable_content_type'] = resolve_variable(self.selectable_content_type, context, self.selectable_content_type)
     base_object_id = values['base_object_id'] = resolve_variable(self.base_object_id, context, self.base_object_id)
     selectable_object_id = values['selectable_object_id'] = resolve_variable(self.selectable_object_id, context, self.selectable_object_id)
     usage = values['usage'] = resolve_variable(self.usage, context, self.usage)
     link_id = values['link_id'] = resolve_variable(self.link_id, context, self.link_id)
     remove_url = values['remove_url'] = resolve_variable(self.remove_url, context, self.remove_url).strip()
     
     script = """<script type='text/javascript'>
                 $("#%(link_id)s").click(function(){
                 $.remove_from_target("%(target_id)s", "%(remove_url)s", "%(base_content_type)s", 
                                     "%(base_object_id)s", "%(selectable_content_type)s", "%(selectable_object_id)s",
                                     "%(usage)s");
                 $.remove_from_data("%(data_id)s", "%(selectable_content_type)s", "%(selectable_object_id)s");
                 return false;});
                 </script>""" % values
     return "\n" + script + "\n"
Ejemplo n.º 7
0
 def render(self,  context):
     values = {}
     link_id = values['link_id'] = resolve_variable(self.link_id, context, self.link_id)
     associate_url = values['associate_url'] = resolve_variable(self.associate_url, context, self.associate_url)
     base_content_type = values['base_content_type'] = resolve_variable(self.base_content_type, context, self.base_content_type)
     base_object_id = values['base_object_id'] = resolve_variable(self.base_object_id, context, self.base_object_id)
     usage = values['usage'] = resolve_variable(self.usage, context, self.usage)
     selectable_content_type = values['selectable_content_type'] = resolve_variable(self.selectable_content_type, context, self.selectable_content_type)
     selectable_object_id = values['selectable_object_id'] = resolve_variable(self.selectable_object_id, context, self.selectable_object_id)
     add = values['add'] = resolve_variable(self.add, context, self.add)
     
     script = """<script type='text/javascript'>
                 $("#%(link_id)s").click(function(){
                 $.modify_content_association("%(associate_url)s", 
                                              "%(base_content_type)s", "%(base_object_id)s", 
                                              "%(selectable_content_type)s", "%(selectable_object_id)s",
                                              "%(usage)s", "%(add)s");
                 return false;});
                 </script>""" % values
     return "\n" + script + "\n"
Ejemplo n.º 8
0
 def render(self,  context):
     base_content_type = resolve_variable(self.base_content_type, context, self.base_content_type)
     base_object_id = resolve_variable(self.base_object_id, context, self.base_object_id)
     usage = resolve_variable(self.usage, context, self.usage)
     update_mode = resolve_variable(self.update_mode, context, self.update_mode)
     associate_url = resolve_variable(self.associate_url, context, self.associate_url)
     iframe_height = resolve_variable(self.iframe_height, context, self.iframe_height)
     iframe_width = resolve_variable(self.iframe_width, context, self.iframe_width)
     resolved_associate_url = reverse(associate_url)
     
     base_content_type_object = ContentType.objects.get(id = int(base_content_type))
     base_content_model = base_content_type_object.model_class()
     if base_object_id > 0:
         base_object = base_content_model.objects.get(id = base_object_id)
     else:
         base_object = None
     
     target_id = generate_target_id(base_content_type, base_object_id)
     data_id = generate_data_id(base_content_type, base_object_id)
     init_id = generate_init_id(base_content_type, base_object_id)
     
     initial_objects = self.get_initial_data(base_object, usage)
     initial_target = render_initial_target(base_object, 
                                            initial_objects, 
                                            target_id, 
                                            data_id, 
                                            associate_url = resolved_associate_url,
                                            usage = usage)
     
     base_url = reverse('django-relatedcontent-select', args=[base_content_type, base_object_id, usage])
     relatedcontent_url = generate_relatedcontent_url(base_url = base_url, 
                                                      mode = update_mode,
                                                      target_id = target_id,
                                                      data_id = data_id,
                                                      ajax_associate_url = associate_url)
     target_url = generate_thickbox_url(relatedcontent_url, iframe_width, iframe_height)
     
     new_context = {}
     new_context['target_id'] = target_id
     new_context['data_id'] = data_id
     new_context['init_id'] = init_id
     new_context['target_url'] = target_url
     new_context['initial_target'] = initial_target
     context['select_link_id'] = init_id
     
     return render_to_string('django_relatedcontent/generate_ajax_select.html', new_context)
Ejemplo n.º 9
0
 def render(self,  context):
     link_id = resolve_variable(self.link_id, context, self.link_id)
     
     return generate_enable_thickbox(link_id)