View | Details | Raw Unified | Return to bug 8123
Collapse All | Expand All

(-)a/tladm/modules/thinlinc/tlwebadm/locations.py (-10 / +11 lines)
Lines 77-101 class WebAdminSection(WebAdminSectionBase): Link Here
77
                      ("", False, []))
77
                      ("", False, []))
78
            selected_location = newloc[0]
78
            selected_location = newloc[0]
79
            search_list['new_name'] = "New location"
79
            search_list['new_name'] = "New location"
80
            search_list['new_location'] = True
80
        elif selected_location and search_list['new_name']:
81
        elif selected_location and search_list['new_name']:
81
            newloc = self.location_from_query(query)
82
            newloc = self.location_from_query(query)
82
            # Rename?
83
            # Rename?
83
            if search_list['new_name'] != selected_location:
84
            if search_list['new_name'] != selected_location:
84
                newloc = (selected_location, newloc[1])
85
                newloc = (selected_location, newloc[1])
85
86
        if newloc:
87
            if newloc[0] not in locations:
88
                search_list['new_location'] = True
86
                search_list['new_location'] = True
87
        elif selected_location and selected_location not in locations:
88
            search_list['new_location'] = True
89
90
        if newloc:
89
            locations[newloc[0]] = newloc[1]
91
            locations[newloc[0]] = newloc[1]
90
92
91
        # FIXME: One reason that selected_location is missing from locations is
93
        if selected_location is not None:
92
        # that it is new, has empty new_name and has not been saved yet. Bug 8123.
93
        if selected_location is not None and selected_location in locations:
94
            search_list["all_printers"] = self._get_current_printerlist()
94
            search_list["all_printers"] = self._get_current_printerlist()
95
            search_list["details"] = {'location': selected_location,
95
            details = locations.get(selected_location, ["", False, []])
96
                                      'description': locations[selected_location][0],
96
            search_list["details"] = { 'location': selected_location,
97
                                      'unknown': locations[selected_location][1],
97
                                       'description': details[0],
98
                                      'printers': locations[selected_location][2]}
98
                                       'unknown': details[1],
99
                                       'printers': details[2] }
99
100
100
        search_list['locations'] = sorted(self.dict_to_list(locations),
101
        search_list['locations'] = sorted(self.dict_to_list(locations),
101
                                          key = lambda t: locale.strxfrm(t[0]))
102
                                          key = lambda t: locale.strxfrm(t[0]))
(-)a/tladm/tests/test_locations.py (-2 / +6 lines)
Lines 356-365 class LocationsTest(BaseTestClass): Link Here
356
        detailed_location = {'description': '', 'location': '__new_entry_1234',
356
        detailed_location = {'description': '', 'location': '__new_entry_1234',
357
                             'printers': [], 'unknown': False}
357
                             'printers': [], 'unknown': False}
358
        wanted_restult = {'add_printer': False,
358
        wanted_restult = {'add_printer': False,
359
                          'details': None,
359
                          'all_printers': ['my_printer'],
360
                          'details': {'description': '',
361
                                      'location': '__new_entry_1234',
362
                                      'printers': [],
363
                                      'unknown': False},
360
                          'errors': ['Location name is required.'],
364
                          'errors': ['Location name is required.'],
361
                          'locations': [],
365
                          'locations': [],
362
                          'new_location': False,
366
                          'new_location': True,
363
                          'new_name': ''}
367
                          'new_name': ''}
364
        self.assertDictEqual(wanted_restult, result)
368
        self.assertDictEqual(wanted_restult, result)
365
369

Return to bug 8123