Changeset 370 in main


Ignore:
Timestamp:
10/04/11 13:04:21 (8 years ago)
Author:
pcosquer
Message:

check if a file can be download and fix tests

Location:
trunk/openPLM/plmapp
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/plmapp/base_views.py

    r369 r370  
    306306        request_dict.session['type'] = 'Part' 
    307307        attributes_form = get_search_form(models.Part) 
    308     if attributes_form.is_valid(): 
    309         if search_need: 
    310             qset = cls.objects.all() 
    311             qset = attributes_form.search(qset)[:30] 
    312             if qset is None: 
    313                 qset = [] 
    314             if issubclass(cls, User): 
    315                 qset = [UserController(u, request_dict.user) for u in qset] 
    316             request_dict.session["results"] = qset 
    317         else: 
    318             qset = request_dict.session["results"]  
     308    if attributes_form.is_valid() and search_need: 
     309        qset = cls.objects.all() 
     310        qset = attributes_form.search(qset)[:30] 
     311        if qset is None: 
     312            qset = [] 
     313        if issubclass(cls, User): 
     314            qset = [UserController(u, request_dict.user) for u in qset] 
     315        request_dict.session["results"] = qset 
    319316    else: 
    320317        qset = request_dict.session.get("results", []) 
  • trunk/openPLM/plmapp/controllers/document.py

    r369 r370  
    252252            part = part.object 
    253253        else: 
    254             if not hasattr(part, "part"): 
     254            if not (isinstance(part, models.PLMObject) and hasattr(part, "part")): 
    255255                raise TypeError("%s is not a part" % part) 
    256256            get_controller(part.type)(part, self._user).check_readable() 
  • trunk/openPLM/plmapp/controllers/part.py

    r369 r370  
    318318            document = document.object 
    319319        else: 
    320             if not hasattr(document, "document"): 
     320            if not (isinstance(document, models.PLMObject) and \ 
     321                    hasattr(document, "document")): 
    321322                raise TypeError("%s is not a document" % document) 
    322323            get_controller(document.type)(document, self._user).check_readable() 
  • trunk/openPLM/plmapp/tests/controllers.py

    r366 r370  
    589589     
    590590    def test_attach_to_part_error1(self): 
    591         self.assertRaises(ValueError, self.controller.attach_to_part, None) 
     591        self.assertRaises(TypeError, self.controller.attach_to_part, None) 
    592592     
    593593    def test_attach_to_part_error2(self): 
    594         self.assertRaises(ValueError, self.controller.attach_to_part, self) 
     594        self.assertRaises(TypeError, self.controller.attach_to_part, self) 
    595595 
    596596    def test_attach_to_part_error3(self): 
     
    598598                           revision="a", creator=self.user, owner=self.user, 
    599599                           group=self.group) 
    600         self.assertRaises(ValueError, self.controller.attach_to_part, obj) 
     600        self.assertRaises(TypeError, self.controller.attach_to_part, obj) 
    601601     
    602602    def test_attach_to_part_error4(self): 
  • trunk/openPLM/plmapp/views/main.py

    r369 r370  
    6666import openPLM.plmapp.forms as forms 
    6767from openPLM.plmapp.base_views import get_obj, get_obj_from_form, \ 
    68         handle_errors, get_generic_data, get_navigate_data 
     68    get_obj_by_id, handle_errors, get_generic_data, get_navigate_data 
    6969 
    7070 
     
    939939    """ 
    940940    doc_file = models.DocumentFile.objects.get(id=docfile_id) 
     941    ctrl = get_obj_by_id(int(doc_file.document.id), request.user) 
     942    ctrl.check_readable() 
    941943    name = doc_file.filename.encode("utf-8", "ignore") 
    942944    mimetype = guess_type(name, False)[0] 
Note: See TracChangeset for help on using the changeset viewer.