Changeset 6423 for branches


Ignore:
Timestamp:
Dec 10, 2008, 11:18:38 AM (16 years ago)
Author:
roland
Message:

added forms stuff

Location:
branches/exodus-roland/exodus
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/exodus-roland/exodus/admin.py

    r6420 r6423  
    3333    )
    3434
    35     #inlines = [InterfaceInline, ]
     35    inlines = [InterfaceInline, ]
    3636
    3737class NodeInline(admin.TabularInline):
  • branches/exodus-roland/exodus/forms.py

    r6421 r6423  
    1111    def clean_masterip(self):
    1212        import pdb; pdb.set_trace() ;
    13         masterip = self.cleaned_data.get('masterip')
     13        new_network = self.cleaned_data.get('network')
     14        #XXX: racing conditions with free_masterip and save()?
     15        # self.instnace.pk is only available when Node has been save before.
    1416        if self.instance.pk is None:
    15             masterip = free_masterip()
    16         if masterip:
    17             pass
    18            
    19            
    20         masterip = self.cleaned_data.get('masterip')
    21     def save(self, commit=True):
    22         import pdb; pdb.set_trace() ;
    23        
     17            masterip = free_masterip(new_network)
     18        else:
     19            # check if network has changed
     20            old_network = Node.objects.get(pk=self.instance.pk).network
     21            if old_network == self.cleaned_data.get('network'):
     22                masterip = self.cleaned_data.get('masterip')
     23            else:
     24                #XXX: Need to update ipconfigurations for depending interfaces
     25                masterip = free_masterip(new_network)
     26        raise forms.ValidationError("Foutmelding van Rick en Roland")
     27        return masterip       
     28
     29    #def save(self, commit):
     30    #    # want to override this, but can't figure out how.
     31    #    super(NodeForm, self).save()
Note: See TracChangeset for help on using the changeset viewer.