예제 #1
0
    def validate_python(self, form_dict, state):
        old_path = form_dict.get('old_path', None)
        parent = form_dict.get('parent', None)
        title_short = form_dict['title_short']
        path = []
        old_location = None

        if old_path:
            old_location = LocationTag.get(old_path)
            # XXX test for id matching a tag
            path = old_location.path
            if len(path) > 0:         # If it's department
                del(path[-1])         # then delete last element
        if parent:
            parent_location = LocationTag.get_by_id(parent)
            path = parent_location.path

        path.append(title_short)
        location = LocationTag.get(path)

        if location is not None and not location is old_location:
            raise Invalid(self.message('duplicate', state),
                          form_dict, state,
                          error_dict={'title_short' : Invalid(self.message('duplicate', state), form_dict, state)})
예제 #2
0
def location_link(location_id):
    from ututi.model import LocationTag

    location = LocationTag.get_by_id(location_id)
    return link_to(location.title, location.url())