Beispiel #1
0
    """Model mapped to the "Genre" table

    Has a custom endpoint ("styles" rather than the default, "genres").
    Only supports HTTP methods specified.
    Has a custom validator for the GET method.

    """

    __tablename__ = 'Genre'
    __endpoint__ = 'styles'
    __methods__ = ('GET', 'DELETE')

    @staticmethod
    def validate_GET(resource=None):
        """Return False if the request should not be processed.

        :param resource: resource related to current request
        :type resource: :class:`sandman.model.Model` or None

        """

        if isinstance(resource, list):
            return True
        elif resource and resource.GenreId == 1:
            return False
        return True


register((Artist, Album, Playlist, Track))
register(Genre)
Beispiel #2
0
    Has a custom endpoint ("styles" rather than the default, "genres").
    Only supports HTTP methods specified.
    Has a custom validator for the GET method.

    """

    __tablename__ = 'Genre'
    __endpoint__ = 'styles'
    __methods__ = ('GET', 'DELETE')

    @staticmethod
    # pylint: disable=invalid-name
    def validate_GET(resource=None):
        """Return False if the request should not be processed.

        :param resource: resource related to current request
        :type resource: :class:`sandman.model.Model` or None

        """

        if isinstance(resource, list):
            return True
        elif resource and resource.GenreId == 1:
            return False
        return True


register((Artist, Album, Playlist, Track, MediaType))
register(Style)
activate(browser=True)
Beispiel #3
0
from sandman import app, db
from sandman.model import activate
app.config['SQLALCHEMY_DATABASE_URI'] = 'monreal.sqlite'

from sandman.model import register, Model

#class Artist(Model):
#    __tablename__ = 'Artist'

#class Album(Model):
#    __tablename__ = 'Album'

#class Playlist(Model):
#    __tablename__ = 'Playlist'

#register((Artist, Album, Playlist))


class monrent(Model):
    __tablename__ = 'monrent'


class plinks(Model):
    __tablename__ = 'plinks'


register((monrent, plinks))
sandman.model.activate_admin_classes
app.run()
Beispiel #4
0
    """Model mapped to the "Genre" table

    Has a custom endpoint ("styles" rather than the default, "genres").
    Only supports HTTP methods specified.
    Has a custom validator for the GET method.

    """

    __tablename__ = 'Genre'
    __endpoint__ = 'styles'
    __methods__ = ('GET', 'DELETE')

    @staticmethod
    def validate_GET(resource=None):
        """Return False if the request should not be processed.

        :param resource: resource related to current request
        :type resource: :class:`sandman.model.Model` or None

        """

        if isinstance(resource, list):
            return True
        elif resource and resource.GenreId == 1:
            return False
        return True

register((Artist, Album, Playlist, Track, MediaType))
register(Genre)
activate_admin_classes()
Beispiel #5
0
from sandman.model import register, Model

class Artist(Model):
    __tablename__ = 'Artist'


class Album(Model):
    __tablename__ = 'Album'

class Playlist(Model):
    __tablename__ = 'Playlist'

class Genre(Model):
    __tablename__ = 'Genre'
    __endpoint__ = 'styles'
    __methods__ = ('GET', 'DELETE')

    @staticmethod
    def do_GET(resource=None):
        if isinstance(resource, list):
            return True
        elif resource and resource.GenreId == 1:
            return False
        return True

register((Artist, Album, Playlist))
register(Genre)
Beispiel #6
0
    for tr in trs:
        elems = tr.find_all('font')
        # Get rid of 'Credits' field.
        del elems[3]
        elem_vals = [course.id] + [elem.text for elem in elems]
        mapped_fields = dict(map(get_co_type, zip(fields, elem_vals)))
        course_offering = CourseOffering(**mapped_fields)
        session.add(course_offering)
        session.commit()


if __name__ == '__main__':
    if len(sys.argv) > 1 and sys.argv[1] == 'initdb':
        from models import init_db
        init_db()

    # get_all_courses()
    # get_all_course_offerings()
    from sandman import app

    app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/catalog.db'

    from sandman.model import register, activate
    from sandman_models import SCourse, SCourseOffering

    register((SCourse, SCourseOffering))
    activate(browser=True)

    app.run()
Beispiel #7
0
        return self.Title


class Playlist(Model):
    __tablename__ = "Playlist"

    def __str__(self):
        return self.Name


class Genre(Model):
    __tablename__ = "Genre"

    def __str__(self):
        return self.Name


class PlaylistTrack(Model):
    __tablename__ = "PlaylistTrack"


class MediaType(Model):
    __tablename__ = "MediaType"

    def __str__(self):
        return self.Name


register((Artist, Album, Playlist, Genre, Track, MediaType, PlaylistTrack))
activate_admin_classes()
Beispiel #8
0
class Album(Model):
    __tablename__ = 'Album'

    def __str__(self):
        return self.Title


class Playlist(Model):
    __tablename__ = 'Playlist'

    def __str__(self):
        return self.Name


class Genre(Model):
    __tablename__ = 'Genre'

    def __str__(self):
        return self.Name


class MediaType(Model):
    __tablename__ = 'MediaType'

    def __str__(self):
        return self.Name


register((Artist, Album, Playlist, Genre, Track, MediaType))
activate_admin_classes()
Beispiel #9
0
from sandman import app, db

app.config['SQLALCHEMY_DATABASE_URI'] = '<your DB's SQLAlchemy connection string>'

from sandman.model import register, Model

class Artist(Model):
    __tablename__ = 'Artist'

class Album(Model):
    __tablename__ = 'Album'

class Playlist(Model):
    __tablename__ = 'Playlist'

register((Artist, Album, Playlist))

app.run()
Beispiel #10
0
from sandman.model import register, Model

class Track(Model):
    __tablename__ = 'Track'

class Artist(Model):
    __tablename__ = 'Artist'

class Album(Model):
    __tablename__ = 'Album'

class Playlist(Model):
    __tablename__ = 'Playlist'

class Genre(Model):
    __tablename__ = 'Genre'

register((Artist, Album, Playlist, Genre, Track))
Beispiel #11
0
        return self.Title


class Playlist(Model):
    __tablename__ = 'Playlist'

    def __str__(self):
        return self.Name


class Type(Model):
    __tablename__ = 'Genre'

    def __str__(self):
        return self.Name


class PlaylistTrack(Model):
    __tablename__ = 'PlaylistTrack'


class MediaType(Model):
    __tablename__ = 'MediaType'

    def __str__(self):
        return self.Name


register((Artist, Album, Playlist, Type, Track, MediaType, PlaylistTrack))
activate(admin=True)
Beispiel #12
0
APP_PATH = os.path.dirname(os.path.abspath(__file__))
DB_PATH = os.path.join(APP_PATH, 'db.sqlite')

app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////' + DB_PATH


from sandman.model import register, activate, Model


class Poll(Model):
    __tablename__ = 'poll_poll'


class Vote(Model):
    __tablename__ = 'poll_vote'


class Item(Model):
    __tablename__ = 'poll_item'


class User(Model):
    __tablename__ = 'auth_user'

# # register can be called with an iterable or a single class
register((Poll, Vote, Item, User))

activate(browser=False)

app.run()
Beispiel #13
0
    'insect_attractor', 'insect_regulator', 'leaf_retention', 'shade_tol',
    'soil_drainage_tol', 'spread_at_maturity', 'sun_needs', 'water_needs'
]

properties_1_to_many = ['family', 'family_common_name', 'url_tags']

properties_many_to_many = [
    'biochemical_material_prod', 'cultural_and_amenity_prod', 'flower_color',
    'foliage_color', 'food_prod', 'fruit_color', 'layer', 'medicinals_prod',
    'mineral_nutrients_prod', 'raw_materials_prod'
]

register((Actions, ActiveGrowthPeriod, Allelopathic, Animals,
          BiochemicalMaterialProd, CanopyDensity, CulturalAndAmenityProd,
          DroughtTol, EndemicStatus, ErosionControl, Family, FloodTol,
          FoodProd, FlowerColor, FoliageColor, FruitColor, HarvestPeriod,
          HumidityTol, Insects, Layer, Lifespan, LeafRetention, MedicinalsProd,
          MineralNutrientsProd, Plants, RawMaterialsProd, Regions, SaltTol,
          ShadeTol, SunNeeds, ToxinRemoval, Toxicity, Transactions, Users,
          WaterNeeds, WindTol))


def delete_plants():
    Plants.query.delete()
    db.session.commit()


def process_transactions():
    for transaction in Transactions.query.filter_by(ignore=False).order_by(
            Transactions.id).all():
        print 'transaction_type = ' + transaction.transaction_type
        print 'plant_id = ' + str(transaction.plants_id)
from sandman.model import register, activate, Model


class JobSchedule(Model):
    __tablename__ = "job_schedule"


class DataSources(Model):
    __tablename__ = "data_sources"


register((JobSchedule, DataSources))
activate(admin=False)
Beispiel #15
0
    """Model mapped to the "Genre" table

    Has a custom endpoint ("styles" rather than the default, "genres").
    Only supports HTTP methods specified.
    Has a custom validator for the GET method.

    """

    __tablename__ = 'Genre'
    __endpoint__ = 'styles'
    __methods__ = ('GET', 'DELETE')

    @staticmethod
    def validate_GET(resource=None):
        """Return False if the request should not be processed.

        :param resource: resource related to current request
        :type resource: :class:`sandman.model.Model` or None

        """

        if isinstance(resource, list):
            return True
        elif resource and resource.GenreId == 1:
            return False
        return True

register((Artist, Album, Playlist, Track, MediaType))
register(Style)
activate()
from sandman.model import register, activate, Model

class JobSchedule(Model):
    __tablename__ = 'job_schedule'

class DataSources(Model):
    __tablename__ = 'data_sources'

register((JobSchedule, DataSources))
activate(admin=False)