Example #1
0
def add_media_to_collection(collection, media, note=None, commit=True):
    collection_item = CollectionItem()
    collection_item.collection = collection.id
    collection_item.media_entry = media.id
    if note:
        collection_item.note = note
    Session.add(collection_item)

    collection.items = collection.items + 1
    Session.add(collection)
    Session.add(media)

    if commit:
        Session.commit()
Example #2
0
def add_media_to_collection(collection, media, note=None, commit=True):
    collection_item = CollectionItem()
    collection_item.collection = collection.id
    collection_item.media_entry = media.id
    if note:
        collection_item.note = note
    Session.add(collection_item)

    collection.items = collection.items + 1
    Session.add(collection)
    Session.add(media)

    if commit:
        Session.commit()
Example #3
0
def add_media_to_collection(collection, media, note=None, commit=True):
    collection_item = CollectionItem()
    collection_item.collection = collection.id
    collection_item.get_object = media
    if note:
        collection_item.note = note
    Session.add(collection_item)

    collection.num_items = collection.num_items + 1
    Session.add(collection)
    Session.add(media)

    hook_runall('collection_add_media', collection_item=collection_item)

    if commit:
        Session.commit()
Example #4
0
def add_media_to_collection(collection, media, note=None, commit=True):
    collection_item = CollectionItem()
    collection_item.collection = collection.id
    collection_item.get_object = media
    if note:
        collection_item.note = note
    Session.add(collection_item)

    collection.num_items = collection.num_items + 1
    Session.add(collection)
    Session.add(media)

    hook_runall('collection_add_media', collection_item=collection_item)

    if commit:
        Session.commit()
Example #5
0
    def add_to_collection(self, obj, content=None, commit=True):
        """ Adds an object to the collection """
        # It's here to prevent cyclic imports
        from mediagoblin.db.models import CollectionItem

        # Need the ID of this collection for this so check we've got one.
        self.save(commit=False)

        # Create the CollectionItem
        item = CollectionItem()
        item.collection = self.id
        item.get_object = obj

        if content is not None:
            item.note = content

        self.num_items = self.num_items + 1

        # Save both!
        self.save(commit=commit)
        item.save(commit=commit)
        return item
Example #6
0
    def add_to_collection(self, obj, content=None, commit=True):
        """ Adds an object to the collection """
        # It's here to prevent cyclic imports
        from mediagoblin.db.models import CollectionItem

        # Need the ID of this collection for this so check we've got one.
        self.save(commit=False)

        # Create the CollectionItem
        item = CollectionItem()
        item.collection = self.id
        item.get_object = obj

        if content is not None:
            item.note = content

        self.num_items = self.num_items + 1

        # Save both!
        self.save(commit=commit)
        item.save(commit=commit)
        return item