Changeset 6495


Ignore:
Timestamp:
Dec 28, 2008, 10:37:48 PM (16 years ago)
Author:
roland
Message:

Added javascript from Rick to show and hide wireless sub menu when
adding/editing an interface.

I also wrote a wrapper for new_ssid, so that I can pass an interface
object to it too.

Location:
trunk/exodus
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/exodus/admin.py

    r6491 r6495  
    3737            'fields' : ('ssid', 'channel', 'antenna', 'polar', 'mode')}),
    3838        )
     39    class Media:
     40        js = ("/static/showandhide.js",)
     41       
    3942
    4043advanced_admin.register(Antenna)
     
    4447advanced_admin.register(Node, NodeAdmin)
    4548advanced_admin.register(Interface, InterfaceAdmin)
    46 #advanced_admin.register(PublicAP)
    4749advanced_admin.register(DhcpStatic)
    4850
     
    5355plain_admin.register(Node)
    5456plain_admin.register(Interface)
    55 #plain_admin.register(PublicAP)
    5657plain_admin.register(DhcpStatic)
    5758
     
    6263databrowse.site.register(Node)
    6364databrowse.site.register(Interface)
    64 #databrowse.site.register(PublicAP)
    6565databrowse.site.register(DhcpStatic)
  • trunk/exodus/forms.py

    r6491 r6495  
    262262    def clean_ssid(self):
    263263        self.type = self.cleaned_data.get('type')
     264        edit = bool(self.instance.pk)
    264265        if not link_is_wireless(self):
    265266            return None
    266 
    267 
     267        if not edit:
     268            return new_ssid
     269
     270       
     271
     272
  • trunk/exodus/wllogic.py

    r6480 r6495  
    99MANAGED = WIFI_MODE_CHOICES[1][0]
    1010
    11 def new_ssid(nic):
     11def new_ssid_for_save_iface(nic):
     12    return new_ssid(nic.node, nic.iface, nic.accesspoint, nic.direction)
     13
     14def new_ssid(node, iface, accesspoint=False, direction=None):
    1215    """Generates a new ssid name for a new wifi NIC.
    1316   
     
    1619    """
    1720
    18     node = nic.node.name
    19     network = nic.node.network.name
     21    nodename = node.name
     22    network = node.network.name
    2023
    21     if nic.accesspoint:
     24    if accesspoint:
    2225        ssid_list = set([i.ssid for i in \
    23                 nic.node.interface_set.filter(accesspoint=True)])
    24         ssid = "ap%%d.%s.%s" % ( node, network)
    25         free_list = ( ssid % (i) for i in range(len(ssid_list)+1) if not
     26                node.interface_set.filter(accesspoint=True)])
     27        ssid = "ap%%s.%s.%s" % ( nodename, network)
     28   
     29        free_list = set()
     30        if (ssid % "") not in ssid_list:
     31            return (ssid % (""))
     32
     33               
     34        # compensate for the first AP. First AP ssid is: ap.nodename.network
     35        # second AP is ap2.nodename.network
     36        free_list = ( ssid % (i) for i in range(2, len(ssid_list)+2) if not
    2637                (ssid %(i) in ssid_list))
    2738        return free_list.next()
    2839
    2940    else:
    30             return "il-%s.%s.%s.%s" % (nic.direction, nic.iface, node, network)
    31 
     41        ssid = "%%S.%s.%s" % (nodename, network)
     42        if direction:
     43            return ssid % (direction)
     44        else:
     45            return ssid % (iface)
     46           
    3247#
    3348# Taken from lvoege@gmail.com's getrange.py
Note: See TracChangeset for help on using the changeset viewer.