source: main/branches/3D/openPLM/document3D/views.py @ 592

Revision 592, 2.7 KB checked in by agalech, 9 years ago (diff)

add document3d app

Line 
1from openPLM.plmapp.base_views import handle_errors , get_generic_data
2from openPLM.document3D.forms import Form3D
3from django.shortcuts import render_to_response
4from django.template import RequestContext
5from openPLM.document3D.models import *
6
7
8
9"""
10def v_3D(request, obj_ref, obj_revi):
11
12    obj_type = "Document3D"         
13    return display_3d(request, obj_type , obj_ref, obj_revi)
14"""   
15def r2r(template, dictionary, request):
16    """
17    Shortcut for::
18       
19        render_to_response(template, dictionary,
20                              context_instance=RequestContext(request))
21    """
22    return render_to_response(template, dictionary,
23                              context_instance=RequestContext(request))
24 
25#@handle_errors
26
27def display_3d(request, obj_ref, obj_revi):
28
29    """ Manage html page for 3D
30 
31    Manage html page which displays the 3d files STEP (or other??) uploaded in the selected object.
32    It computes a context dictionnary based on
33   
34    .. include:: views_params.txt
35    """
36   
37    obj_type = "Document3D"
38   
39    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi)
40
41   
42   
43   
44   
45    if request.method == 'POST':
46        form = Form3D(request.POST, document=obj)
47        if form.is_valid():
48            options = form.cleaned_data
49            image = options["Display"]
50            multi_image=stp_to_jss.objects.filter(stp=image)
51
52            #ctx.update({'current_page':'3D','select_stp_form': form,'images_3D':options["Display"].js.name})
53            ctx.update({'current_page':'3D','select_stp_form': form, 'multi_image3D' : multi_image})   
54            return r2r('Display3D.htm', ctx, request)
55       
56    else:
57        form = Form3D(document=obj)
58       
59 
60    image = form.fields["Display"].initial
61
62    if image is None:
63        multi_image=''
64
65    else:
66
67        multi_image=stp_to_jss.objects.filter(stp=image)
68       
69        #print "EL numero de ficheros es " ,multi_image.count()
70
71       
72    ctx.update({'current_page':'3D','select_stp_form': form , 'multi_image3D' : multi_image ,})
73 
74    return r2r('Display3D.htm', ctx, request)
75
76
77   
78   
79   
80    #print "el total es"
81    #print stps.count()
82    #print stps[0].file.path
83
84
85               
86               
87
88    #if not hasattr(obj, "files"):
89    #    raise TypeError()
90    #if request.method == "POST":
91    #    formset = get_file_formset(obj, request.POST)
92    #    if formset.is_valid():
93    #        obj.update_file(formset)
94    #        return HttpResponseRedirect(".")
95    #else:
96    #    formset = get_file_formset(obj)
97    #ctx.update({'current_page':'3D',
98    #            'file_formset': formset})
99    #return r2r('3d.htm', ctx, request)
100##########################################################################################
Note: See TracBrowser for help on using the repository browser.