Exemplo n.º 1
0
def set_expires():
    """Set the expiry date for an asset"""

    # Validate the parameters
    form = SetExpiresForm(request.values)
    if not form.validate():
        return fail('Invalid request', issues=form.errors)
    form_data = form.data

    # Get the asset
    asset = Asset.one(And(Q.account == g.account, Q.uid == form_data['uid']))

    # Update the assets `expires` value
    if 'expires' in form_data:
        # Set `expires`
        asset.expires = form_data['expires']
        asset.update('expires', 'modified')

    else:
        # Unset `expires`
        Asset.get_collection().update({'_id': asset._id},
                                      {'$unset': {
                                          'expires': ''
                                      }})
        asset.update('modified')

    return success()
Exemplo n.º 2
0
    def run(self):

        # Confirm the drop
        if not self.confirm('Enter the following string to confirm drop', \
                    'hangar51'):
            return

        # Delete all accounts, assets and files
        accounts = Account.many()
        for account in accounts:
            account.purge()

        # Drop the collections
        Asset.get_collection().drop()
        Account.get_collection().drop()