Changeset 360 in main


Ignore:
Timestamp:
10/03/11 08:48:21 (8 years ago)
Author:
pcosquer
Message:

add a group attribute to PLMObject

South ( http://south.aeracode.org/docs/index.html) is now a dependancy.
This commit modify an existant model.
To migrate:

  • save your database
  • make sure your installation was up-to-date with the revision 359
  • make sure you have at least one GroupInfo?
  • run the following commands:

./manage.py syncdb
./manage.py migrate --fake

Location:
trunk/openPLM
Files:
17 added
6 edited

Legend:

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

    r355 r360  
    404404                                 auto_now_add=False) 
    405405    mtime = models.DateTimeField(_("date of last modification"), auto_now=True) 
     406    group = models.ForeignKey(GroupInfo, related_name="%(class)s_group") 
    406407 
    407408    # state and lifecycle 
     
    412413                              related_name="%(class)s_lifecyle", 
    413414                              default=get_default_state) 
    414  
     415     
    415416     
    416417    class Meta: 
     
    473474    def attributes(self): 
    474475        u"Attributes to display in `Attributes view`" 
    475         return ["name",  "creator", "owner", "ctime", "mtime"] 
     476        return ["name",  "creator", "owner", "group", "ctime", "mtime"] 
    476477 
    477478    @property 
     
    514515        :meth:`excluded_modification_fields` 
    515516        """ 
    516         return [ugettext_noop("creator"), ugettext_noop("owner"), ugettext_noop("ctime"), ugettext_noop("mtime")] 
     517        return [ugettext_noop("creator"), ugettext_noop("owner"), ugettext_noop("ctime"), ugettext_noop("mtime"), ugettext_noop("group")] 
    517518 
    518519    @classmethod 
  • trunk/openPLM/plmapp/tests/controllers.py

    r333 r360  
    5757        self.user.get_profile().is_contributor = True 
    5858        self.user.get_profile().save() 
     59        self.group = GroupInfo(name="grp", owner=self.user, creator=self.user, 
     60                description="grp") 
     61        self.group.save() 
     62        self.user.groups.add(self.group) 
     63        self.DATA["group"] = self.group 
    5964 
    6065    def test_create(self): 
     
    437442        self.controller = self.CONTROLLER.create("adoc", self.TYPE, "a", 
    438443                                                 self.user, self.DATA) 
    439         self.part = PartController.create("mpart", "Part", "a", self.user) 
     444        self.part = PartController.create("mpart", "Part", "a", self.user, 
     445                self.DATA) 
    440446        self.old_files = [] 
    441447 
     
    585591    def test_attach_to_part_error3(self): 
    586592        obj = PLMObject.objects.create(reference="obj", type="PLMObject", 
    587                            revision="a", creator=self.user, owner=self.user) 
     593                           revision="a", creator=self.user, owner=self.user, 
     594                           group=self.group) 
    588595        self.assertRaises(ValueError, self.controller.attach_to_part, obj) 
    589596     
  • trunk/openPLM/plmapp/tests/views.py

    r261 r360  
    4848        self.user.get_profile().is_contributor = True 
    4949        self.user.get_profile().save() 
     50        self.group = GroupInfo(name="grp", owner=self.user, creator=self.user, 
     51                description="grp") 
     52        self.group.save() 
     53        self.user.groups.add(self.group) 
     54        self.DATA["group"] = self.group 
    5055        self.client.post("/login/", {'username' : 'user', 'password' : 'password'}) 
    5156        self.controller = self.CONTROLLER.create("Part1", self.TYPE, "a", 
     
    7075        response = self.client.get("/object/create/", 
    7176                                   {"type" : self.TYPE, "reference" : "mapart", 
    72                                     "revision" : "a", "name" : "MaPart"}) 
     77                                    "revision" : "a", "name" : "MaPart", 
     78                                    "group" : str(self.group.id)}) 
    7379 
    7480        self.assertEqual(response.status_code, 200) 
     
    170176        PLMObject.objects.create(reference="aa", type="PLMObject",  
    171177                                     revision="c", owner=self.user, 
    172                                      creator=self.user) 
     178                                     creator=self.user, group=self.group) 
    173179        results = self.search({"type" : self.TYPE})  
    174180        self.assertEqual(results, [self.controller.object]) 
     
    236242        self.user.get_profile().is_contributor = True 
    237243        self.user.get_profile().save() 
     244        self.group = GroupInfo(name="grp", owner=self.user, creator=self.user, 
     245                description="grp") 
     246        self.group.save() 
     247        self.user.groups.add(self.group) 
    238248        self.client.post("/login/", {'username' : 'user', 'password' : 'password'}) 
    239         self.controller = self.CONTROLLER.create("Part1", "Part", "a", owner) 
     249        self.controller = self.CONTROLLER.create("Part1", "Part", "a", owner, 
     250                {"group":self.group}) 
    240251        self.base_url = "/object/%s/%s/%s/" % (self.controller.type, 
    241252                                              self.controller.reference, 
  • trunk/openPLM/settings.py

    r279 r360  
    99 
    1010ADMINS = ( 
    11     # ('Your Name', 'your_email@domain.com'), 
    12     ("pcosquer", "pierre.cosquer@insa-rennes.fr"), 
    13     ("pjoulaud", "ninoo.fr@gmail.com"), 
     11    ('Your Name', 'your_email@domain.com'), 
    1412) 
    1513 
     
    9391    'django.contrib.sites', 
    9492    'django.contrib.admin', 
     93    'south', 
    9594    'openPLM.plmapp', 
    9695    # you can add your application after this line 
     
    129128#: Max file size for documents in bytes, -1 means illimited 
    130129MAX_FILE_SIZE = -1 
     130 
     131#: True if emails must have a domain of the list of sites 
     132RESTRICT_EMAIL_TO_DOMAINS = False 
     133 
  • trunk/openPLM/settings.py.postgre

    r238 r360  
    1010ADMINS = ( 
    1111    # ('Your Name', 'your_email@domain.com'), 
    12     ("pcosquer", "pierre.cosquer@insa-rennes.fr"), 
    13     ("pjoulaud", "ninoo.fr@gmail.com"), 
    1412) 
    1513 
     
    9391    'django.contrib.sites', 
    9492    'django.contrib.admin', 
     93    'south', 
    9594    'openPLM.plmapp', 
    9695    # you can add your application after this line 
     
    129128#: Max file size for documents in bytes, -1 means illimited 
    130129MAX_FILE_SIZE = -1 
     130 
     131RESTRICT_EMAIL_TO_DOMAINS = False 
     132 
  • trunk/openPLM/settings.py.sqlite

    r238 r360  
    1010ADMINS = ( 
    1111    # ('Your Name', 'your_email@domain.com'), 
    12     ("pcosquer", "pierre.cosquer@insa-rennes.fr"), 
    13     ("pjoulaud", "ninoo.fr@gmail.com"), 
    1412) 
    1513 
     
    129127#: Max file size for documents in bytes, -1 means illimited 
    130128MAX_FILE_SIZE = -1 
     129 
     130RESTRICT_EMAIL_TO_DOMAINS = False 
     131 
Note: See TracChangeset for help on using the changeset viewer.