Ejemplo n.º 1
0
def reorder_list_items(list_id, list_item_ids, user):
    list = get_list_by_id(list_id)
    if not check_list_ownership(list, user.id):
        return False, 401

    for item in list.listItems:
        item.rank = len(list_item_ids) - list_item_ids.index(item.id)
    db.get_session().commit()
    return list, 200
Ejemplo n.º 2
0
def edit_existing_list(client_list, user):
    list = get_list_by_id(client_list["list_id"])
    if not check_list_ownership(list, user.id):
        return False, 401
    list.name = client_list["name"]
    list.image = client_list["image"]

    db.get_session().commit()
    return list, 200
Ejemplo n.º 3
0
def edit_existing_list_item(list_item, user):
    existing_item = get_list_item_by_id(list_item["list_item_id"])
    list = get_list_by_id(list_item["list_id"])
    if not check_list_ownership(list, user.id):
        return False, 401

    existing_item.name = list_item["name"]
    existing_item.body = list_item["body"]
    existing_item.yt_video = list_item["yt_video"]

    db.get_session().commit()
    list = get_list_by_id(list_item["list_id"])
    return list, 200
Ejemplo n.º 4
0
def add_new_list_item(list_item, user):
    list = get_list_by_id(list_item["list_id"])
    if not check_list_ownership(list, user.id):
        return False, 401

    rank = list_item.get("rank")
    if not rank:
        rank = 1
        for item in list.list_items:
            rank += 1
    item = ListItem(list_item["list_id"], rank, list_item["name"], list_item["body"], list_item.get("image"),
                    list_item.get("yt_video"))
    db.get_session().add(item)
    db.get_session().commit()
    list = get_list_by_id(list_item["list_id"])
    return list, 200
Ejemplo n.º 5
0
    def __init__(self, root, master):
        ImportDialog.singleton = True  # creation of a pseudo singleton

        logger.info('Instantiating ImportDialog')
        Toplevel.__init__(self, root)
        self.transient(root)

        self.protocol('WM_DELETE_WINDOW', self.free)
        self.session = db.get_session()  # import window holds a session
        self.__internal_list = list()  # internal list of db objs
        self.__stack = collections.deque(maxlen=15)  # stack for searching
        self.__search_string = ''  # search string
        self.__master = master  # CALIPSO class
        self.__root = root
        self.title('Import from existing database')  # window title
        self.tree = None  # tree viewing class
        self.e = None  # entry box for searching
        self.top_frame = None  # top Tkinter frame
        self.bottom_frame = None  # bottom Tkinter frame
        self.bottom_button_frame = None  # bottom BUTTON Tkinter frame
        self.separator = None  # separator line
        self.filter_file = IntVar()  # int_var for filtering by file
        self.advance_dialog = False
        self.extract_dialog = False
        self.column_titles = [
            'name', 'plot', 'time range', 'latitude range', 'altitude range',
            'attributes', 'notes', 'last edited', 'file'
        ]

        self.plot_type = StringVar()
        self.beg_time = None
        self.end_time = None
        self.beg_lat = None
        self.end_lat = None
        self.beg_alt = None
        self.end_alt = None
        self.file = None

        center(self, (constants.IMPORTWIDTH, constants.IMPORTHEIGH))

        self.container = Frame(self)  # create center frame,
        self.container.pack(side=TOP, fill=BOTH, expand=True)  # place

        self.create_top_frame(
        )  # create the top frame and pack buttons / etc. on it
        self.create_bottom_frame()  # create the bottom frame and pack
Ejemplo n.º 6
0
def add_new_list(client_list, user):
    list = List(client_list["name"], user.id, user.name, client_list.get("image"))
    db.get_session().add(list)
    db.get_session().commit()
    return list