Changeset 1420 in main


Ignore:
Timestamp:
07/11/12 09:15:25 (9 years ago)
Author:
pcosquer
Message:

views: documents, renames display_parts/add_parts

Location:
trunk/openPLM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/tests/views.py

    r1419 r1420  
    598598        response = self.get(self.base_url + "parts/", page="parts") 
    599599        self.assertEqual([part.id], 
    600                          [p.part.id for p in response.context["all_parts"]]) 
     600                         [p.part.id for p in response.context["parts"]]) 
    601601        self.assertEqual([part.id], 
    602602            [f.instance.part.id for f in response.context["parts_formset"].forms]) 
     
    623623            } 
    624624        response = self.post(self.base_url + "parts/", data, page="parts") 
    625         self.assertEqual(1, response.context["all_parts"].count()) 
     625        self.assertEqual(1, response.context["parts"].count()) 
    626626        self.assertEqual(list(part2.get_attached_documents()),  
    627                          list(response.context["all_parts"])) 
     627                         list(response.context["parts"])) 
    628628        forms_ = response.context["forms"] 
    629629        self.assertEqual([part2.id], 
     
    651651            } 
    652652        response = self.post(self.base_url + "parts/", data, page="parts") 
    653         self.assertEqual(2, response.context["all_parts"].count()) 
     653        self.assertEqual(2, response.context["parts"].count()) 
    654654        forms_ = response.context["forms"] 
    655655        self.assertEqual(set((part1.id, part2.id)),  
     
    677677            } 
    678678        response = self.post(self.base_url + "parts/", data, page="parts") 
    679         self.assertEqual(0, response.context["all_parts"].count()) 
     679        self.assertEqual(0, response.context["parts"].count()) 
    680680        self.assertFalse(response.context["forms"]) 
    681681         
    682682    def test_add_related_part_get(self): 
    683683        response = self.get(self.base_url + "parts/add/", link=True) 
    684         self.assertTrue(isinstance(response.context["add_rel_part_form"], 
     684        self.assertTrue(isinstance(response.context["add_part_form"], 
    685685                                   forms.AddRelPartForm)) 
    686686        attach = response.context["attach"] 
  • trunk/openPLM/plmapp/views/main.py

    r1419 r1420  
    12001200############################################################################################# 
    12011201@handle_errors 
    1202 def display_related_part(request, obj_type, obj_ref, obj_revi): 
    1203     """ 
    1204     Manage html page which displays the related part of (:class:`DocumentPartLink` with) the selected object. 
    1205     It computes a context dictionary based on 
    1206      
    1207     .. include:: views_params.txt  
     1202def display_parts(request, obj_type, obj_ref, obj_revi): 
     1203    """ 
     1204    Attached parts view. 
     1205     
     1206    That view displays the parts attached to the selected object that must be a document. 
     1207     
     1208    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/parts/` 
     1209     
     1210    .. include:: views_params.txt 
     1211 
     1212    **Template:** 
     1213     
     1214    :file:`documents/parts.html` 
     1215 
     1216    **Context:** 
     1217 
     1218    ``RequestContext`` 
     1219    
     1220    ``parts`` 
     1221        a queryset of :class:`.DocumentPartLink` bound to the document 
     1222 
     1223    ``parts_formset`` 
     1224        a formset to detach parts 
     1225 
     1226    ``forms`` 
     1227        a dictionary (link_id -> form) to get the form related to a link 
     1228        (a part may not be "detachable") 
    12081229    """ 
    12091230    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
     
    12211242 
    12221243    ctx.update({'current_page':'parts',  
    1223                 'all_parts': obj.get_attached_parts(), 
     1244                'parts': obj.get_attached_parts(), 
    12241245                'forms' : rforms, 
    12251246                'parts_formset': formset}) 
     
    12281249##########################################################################################     
    12291250@handle_errors 
    1230 def add_rel_part(request, obj_type, obj_ref, obj_revi): 
    1231     """ 
    1232     Manage html page for link creation (:class:`DocumentPartLink` link) between the selected object and some parts. 
    1233     It computes a context dictionary based on 
    1234      
    1235     .. include:: views_params.txt  
     1251def add_part(request, obj_type, obj_ref, obj_revi): 
     1252    """ 
     1253    View to attach a part to a document. 
     1254 
     1255    :url: :samp:`/object/{obj_type}/{obj_ref}/{obj_revi}/parts/add/` 
     1256     
     1257    .. include:: views_params.txt 
     1258 
     1259    **Template:** 
     1260     
     1261    :file:`documents/parts_add.html` 
     1262 
     1263    **Context:** 
     1264 
     1265    ``RequestContext`` 
     1266    
     1267    ``add_part_form`` 
     1268        a form to attach a part (:class:`.AddRelPartForm`) 
     1269 
     1270    ``link_creation`` 
     1271        Set to True 
     1272 
     1273    ``attach`` 
     1274        set to (*obj*, "attach_part") 
    12361275    """ 
    12371276    obj, ctx = get_generic_data(request, obj_type, obj_ref, obj_revi) 
    12381277     
    12391278    if request.POST: 
    1240         add_rel_part_form = forms.AddRelPartForm(request.POST) 
    1241         if add_rel_part_form.is_valid(): 
    1242             part_obj = get_obj_from_form(add_rel_part_form, request.user) 
     1279        add_part_form = forms.AddRelPartForm(request.POST) 
     1280        if add_part_form.is_valid(): 
     1281            part_obj = get_obj_from_form(add_part_form, request.user) 
    12431282            obj.attach_to_part(part_obj) 
    12441283            return HttpResponseRedirect(obj.plmobject_url + "parts/") 
    12451284    else: 
    1246         add_rel_part_form = forms.AddRelPartForm() 
     1285        add_part_form = forms.AddRelPartForm() 
    12471286    ctx.update({'link_creation': True, 
    1248                 'add_rel_part_form': add_rel_part_form, 
     1287                'add_part_form': add_part_form, 
    12491288                'attach' : (obj, "attach_part") }) 
    12501289    return r2r('documents/parts_add.html', ctx, request) 
  • trunk/openPLM/templates/documents/parts.html

    r1241 r1420  
    5252 
    5353        <table class="Content"> 
    54             {% for link in all_parts %} 
     54            {% for link in parts %} 
    5555 
    5656                <tr class="Content"> 
  • trunk/openPLM/templates/documents/parts_add.html

    r808 r1420  
    55 
    66{% block content %}  
    7     {% with add_rel_part_form as form %} 
     7    {% with add_part_form as form %} 
    88        {% include "snippets/undo_form.html" %} 
    99    {% endwith %} 
  • trunk/openPLM/urls.py

    r1419 r1420  
    120120    (r'doc-cad/$', display_doc_cad), 
    121121    (r'doc-cad/add/$', add_doc_cad), 
    122     (r'parts/$', display_related_part), 
    123     (r'parts/add/$', add_rel_part), 
     122    (r'parts/$', display_parts), 
     123    (r'parts/add/$', add_part), 
    124124    (r'files/$', display_files), 
    125125    (r'files/add/$', add_file), 
Note: See TracChangeset for help on using the changeset viewer.