Exemplo n.º 1
0
class Domain(orm.Model):
    __tablename__ = "domains"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    name = orm.String(max_length=100, unique=True)
    registrar = orm.ForeignKey(Registrar)
    dns = orm.ForeignKey(DNSProvider, allow_null=True)
    site = orm.ForeignKey(Site, allow_null=True)
    waf = orm.ForeignKey(WAFProvider, allow_null=True)
    update_apex = orm.Boolean(default=True)
    update_a_records = orm.Text(default="www")
    google_site_verification = orm.String(max_length=64, allow_null=True)
    state = orm.Text(default="{}")
    active = orm.Boolean(default=True)

    async def serialize(self, full=False):
        r = {
            "id": self.id,
            "name": self.name,
        }
        if self.registrar.id:
            r["registrar"] = await self.registrar.serialize()
        if self.dns.id:
            r["dns"] = await self.dns.serialize()
        if self.site.id:
            r["site"] = await self.site.serialize()
        if self.waf.id:
            r["waf"] = await self.waf.serialize()
        if self.active:
            r["active"] = True
        return r
Exemplo n.º 2
0
class Articles(BaseModel):
    __tablename__ = 'articles'
    __database__ = database
    __metadata__ = metadata

    title = orm.String(max_length=255, allow_null=True)
    summary = orm.String(max_length=255, allow_null=True)
    views = orm.Integer(default=0)
    comment_num = orm.Integer(default=0)
    weight = orm.Integer(default=0)
    content = orm.Text()  # txt
    content_html = orm.Text()  # html
    is_hot = orm.Boolean(default=False)
    key_words = orm.String(max_length=255, allow_null=True)
    tag_id = orm.ForeignKey(
        Tags,
        allow_null=True
    )

    user_id = orm.ForeignKey(
        User,
        allow_null=True
    )

    def __str__(self):
        return self.title
Exemplo n.º 3
0
 class PISAInterfaceDict(orm.Model):
     __tablename__ = 'PISAInterfaceDict'
     __metadata__ = self.metadata
     __database__ = self.database
     entity_id_1 = orm.Integer()
     chain_id_1 = orm.String(max_length=50)
     struct_asym_id_1 = orm.String(max_length=50)
     struct_asym_id_in_assembly_1 = orm.String(max_length=50)
     asym_id_rank_1 = orm.Integer()
     model_id_1 = orm.Integer()
     molecule_type_1 = orm.Text()
     surface_range_1 = orm.JSON(allow_null=True)
     interface_range_1 = orm.JSON(allow_null=True)
     entity_id_2 = orm.Integer()
     chain_id_2 = orm.String(max_length=50)
     struct_asym_id_2 = orm.String(max_length=50)
     struct_asym_id_in_assembly_2 = orm.String(max_length=50)
     asym_id_rank_2 = orm.Integer()
     model_id_2 = orm.Integer()
     molecule_type_2 = orm.Text()
     surface_range_2 = orm.JSON(allow_null=True)
     interface_range_2 = orm.JSON(allow_null=True)
     pdb_id = orm.String(max_length=4, primary_key=True)
     assembly_id = orm.Integer(primary_key=True)
     interface_id = orm.Integer(primary_key=True)
     use_au = orm.Boolean()
     css = orm.Float()
     is_polymer_1 = orm.Boolean()
     is_polymer_2 = orm.Boolean()
Exemplo n.º 4
0
class Message(orm.Model):
    __tablename__ = "message"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    subject = orm.Text(allow_null=False)
    message = orm.Text(allow_null=False)
Exemplo n.º 5
0
class Good(orm.Model):
    __metadata__ = metadata
    __database__ = database
    __tablename__ = "goods"

    id = orm.Integer(primary_key=True)
    name = orm.Text()
    product_url = orm.Text()
    image_url = orm.Text()
    price = orm.Text()
    combination = orm.ForeignKey(Combination)
Exemplo n.º 6
0
class Post(orm.Model):
    __tablename__ = "posts"
    __database__ = database
    __metadata__ = metadata
    objects = PostQuerySet()

    id = orm.Integer(primary_key=True)

    title = orm.String(max_length=300)
    description = orm.Text(allow_blank=True)  # Social cards and RSS
    content = orm.Text(allow_blank=True)

    created = orm.DateTime(index=True)
    modified = orm.DateTime(index=True)
    published = orm.DateTime(allow_null=True)

    image_url = URLField(allow_null=True)
    image_caption = orm.Text(allow_null=True)

    @property
    def is_published(self) -> bool:
        return self.published is not None

    async def update(self, **kwargs) -> None:
        kwargs["modified"] = datetime.now()
        await super().update(**kwargs)

    async def publish(self):
        assert not self.is_published
        await self.update(published=datetime.now())

    async def _get_relative_id(self,
                               previous: bool = True) -> typing.Optional[int]:
        if not self.published:
            return None

        filters = {
            "published__lt" if previous else "published__gt": self.published
        }
        order_by = ("-" if previous else "") + "published"

        results = await (Post.objects.published_only().filter(
            **filters).order_by(order_by).all())

        return results[0].id if results else None

    async def get_previous_id(self) -> typing.Optional[int]:
        return await self._get_relative_id(previous=True)

    async def get_next_id(self) -> typing.Optional[int]:
        return await self._get_relative_id(previous=False)
Exemplo n.º 7
0
 class INFO(orm.Model):
     __tablename__ = 'INFO'
     __metadata__ = self.metadata
     __database__ = self.database
     accession = orm.String(max_length=100, primary_key=True)
     id = orm.String(max_length=100)
     proteinExistence = orm.Text(allow_null=True, allow_blank=True)
     info = orm.JSON()
     organism = orm.JSON()
     secondaryAccession = orm.JSON(allow_null=True)
     protein = orm.JSON()
     gene = orm.JSON()
     sequence = orm.Text()
     length = orm.Integer()
Exemplo n.º 8
0
 class INTERACTION(orm.Model):
     __tablename__ = 'INTERACTION'
     __metadata__ = self.metadata
     __database__ = self.database
     accession1 = orm.String(max_length=100, primary_key=True)
     accession2 = orm.String(max_length=100, primary_key=True)
     gene = orm.String(max_length=100,
                       allow_null=True,
                       allow_blank=True)
     interactor1 = orm.String(max_length=100, primary_key=True)
     interactor2 = orm.String(max_length=100, primary_key=True)
     organismDiffer = orm.Boolean()
     experiments = orm.Integer()
     chain1 = orm.Text(allow_null=True, allow_blank=True)
     chain2 = orm.Text(allow_null=True, allow_blank=True)
     accession = orm.String(max_length=50, primary_key=True)
Exemplo n.º 9
0
class WSTournamentEn(ReceiverImagesMixin):
    """Weiß Schwarz - English Edition - Monthly Shop Tournament Card service. This is a receiver service.
    Get all English Edition - Monthly Shop Tournament Cards."""

    MODULE = "Weiß Schwarz - English Tournament"
    MODELS_METADATA, MODEL_IDENTIFIER, MODELS = identifier_factory(
        orm.Text(primary_key=True))

    _EN_URL = 'https://en.ws-tcg.com/events/'

    _PUBLIC_URL = True

    _RECEIVER_CONFIG = ReceiverConfig

    async def _load_publications(self):
        html = await self._get_site_content(url=self._EN_URL)
        beautiful_soap = BeautifulSoup(html, 'html5lib')
        months = beautiful_soap.findAll('div', class_='monthWrap')

        for month in months:
            cards = month.findAll('img')
            title_str = self._add_html_tag(month.find('h4').text.strip(),
                                           tag=self._TITLE_HTML_TAG)
            title = RichText(data=title_str, format_data=FormatData.HTML)

            for card in cards:
                publication = await self._create_publication_from_img(
                    img=card, rich_title=title)
                if publication:
                    transaction_data = TransactionData(
                        transaction_id=publication.publication_id,
                        publications=[publication])
                    await self._put_in_queue(transaction_data=transaction_data)
Exemplo n.º 10
0
class Combination(orm.Model):
    __metadata__ = metadata
    __database__ = database
    __tablename__ = "combinations"

    id = orm.Integer(primary_key=True)
    name = orm.Text()
    language = orm.ForeignKey(Language)
Exemplo n.º 11
0
 class profile_id(orm.Model):
     __tablename__ = 'profile_id'
     __metadata__ = self.metadata
     __database__ = self.database
     pdb_id = orm.String(max_length=4, primary_key=True)
     entity_id = orm.Integer(primary_key=True)
     molecule_type = orm.Text()  # redundant
     chain_id = orm.String(max_length=10)  # redundant
     struct_asym_id = orm.String(max_length=10, primary_key=True)
     assembly_id = orm.Integer(primary_key=True)
     model_id = orm.Integer()
     asym_id_rank = orm.Integer()
     oper_expression = orm.Text(allow_blank=True)
     symmetry_operation = orm.Text(allow_blank=True)
     symmetry_id = orm.Text(allow_blank=True)
     struct_asym_id_in_assembly = orm.Integer(primary_key=True)
     au_subset = orm.Boolean()
     details = orm.Text()
Exemplo n.º 12
0
 class FEATURES(orm.Model):
     __tablename__ = 'features'
     __metadata__ = self.metadata
     __database__ = self.database
     type = orm.String(primary_key=True, max_length=100)
     category = orm.String(primary_key=True, max_length=100)
     description = orm.Text(allow_null=True, allow_blank=True)
     begin = orm.Integer(primary_key=True)
     end = orm.Integer(primary_key=True)
     molecule = orm.String(primary_key=True,
                           max_length=100,
                           allow_blank=True)
     ftId = orm.String(max_length=100,
                       allow_null=True,
                       allow_blank=True)
     evidences = orm.JSON(allow_null=True)
     alternativeSequence = orm.Text(allow_null=True, allow_blank=True)
     accession = orm.String(primary_key=True, max_length=100)
Exemplo n.º 13
0
class PythonPackage(orm.Model):
    __tablename__ = "python_packages"
    __database__ = context.database
    __metadata__ = context.metadata

    id = orm.Integer(primary_key=True)
    user_id = orm.Integer(allow_null=True, index=True)

    name = orm.Text(allow_null=False, index=True)
    author = orm.Text(allow_null=True)
    summary = orm.Text(allow_null=True)
    license = orm.Text(allow_null=True)
    keywords = orm.Text(allow_null=True)
    home_page = orm.Text(allow_null=True)
    maintainer = orm.Text(allow_null=True)
    project_urls = orm.Text(allow_null=True)
    author_email = orm.Text(allow_null=True)
    maintainer_email = orm.Text(allow_null=True)

    @staticmethod
    def cast_dist_info_to_data(upload: DistInfoModel) -> Dict[str, Any]:
        return dict(
            name=upload.name,
            summary=upload.summary,
            license=upload.license,
            keywords=upload.keywords,
            home_page=upload.home_page,
            author=upload.author,
            author_email=upload.author_email,
            project_urls=";".join(upload.project_urls) if upload.project_urls else None,
            maintainer=upload.maintainer,
            maintainer_email=upload.maintainer_email,
        )

    @classmethod
    async def create_by_dist_info(
        cls, *, upload: DistInfoModel, user_id: Optional[int]
    ) -> "PythonPackage":
        upload_dict = cls.cast_dist_info_to_data(upload)
        return await cls.objects.create(**upload_dict, user_id=user_id)

    async def update_by_dist_info(self, upload: DistInfoModel) -> None:
        upload_dict = self.cast_dist_info_to_data(upload)
        await self.update(**upload_dict)
Exemplo n.º 14
0
 class rcsb_cluster_membership(orm.Model):
     __tablename__ = 'rcsb_cluster_membership'
     __metadata__ = self.metadata
     __database__ = self.database
     rcsb_id = orm.Text()
     score = orm.Float()
     identity = orm.Integer(primary_key=True)
     cluster_id = orm.Integer(primary_key=True)
     pdb_id = orm.String(max_length=4, primary_key=True)
     entity_id = orm.Integer(primary_key=True)
Exemplo n.º 15
0
class WeiBo(orm.Model):
    __tablename__ = "weibo"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    title = orm.String(max_length=255, allow_null=True, allow_blank=True)
    publish_time = orm.String(max_length=20, allow_null=True, allow_blank=True)
    content = orm.Text(allow_null=True, allow_blank=True)
    group = orm.String(max_length=20, allow_null=True, allow_blank=True)
Exemplo n.º 16
0
class Post(orm.Model):
    __tablename__ = 'posts'
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    thread = orm.ForeignKey(Thread)
    offset = orm.Integer()
    markdown = orm.Text()
    datetime = orm.DateTime(default=datetime.datetime.now)
Exemplo n.º 17
0
class Todo(orm.Model):
    __tablename__ = "todo"
    __metadata__ = metadata
    __database__ = database
    id = orm.Integer(primary_key=True)
    created = orm.DateTime(default=datetime.datetime.now)
    modified = orm.DateTime(default=datetime.datetime.now,
                            onupdate=datetime.datetime.now)
    description = orm.Text(allow_blank=True)
    value = orm.Float(allow_null=True)
    data = orm.JSON(default={})
Exemplo n.º 18
0
class Spiders(orm.Model):
    __tablename__ = "spiders"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    title = orm.String(max_length=255, allow_null=True, allow_blank=True)
    publish_time = orm.String(max_length=20, allow_null=True, allow_blank=True)
    content = orm.Text(allow_null=True, allow_blank=True)
    group = orm.String(max_length=20, allow_null=True, allow_blank=True)
    is_activated = orm.Boolean(default=False)
Exemplo n.º 19
0
class HotData(orm.Model):

    __tablename__ = "hotdata"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    title = orm.String(max_length=30, allow_null=False)
    info = orm.Text()
    search_num = orm.Boolean(default=False, allow_null=False)
    created_at = orm.DateTime()
Exemplo n.º 20
0
class Example(orm.Model):
    __tablename__ = "example"
    __metadata__ = metadata
    __database__ = database

    id = orm.Integer(primary_key=True)
    created = orm.DateTime(default=datetime.datetime.now)
    created_day = orm.Date(default=datetime.date.today)
    created_time = orm.Time(default=time)
    description = orm.Text(allow_blank=True)
    value = orm.Float(allow_null=True)
    data = orm.JSON(default={})
Exemplo n.º 21
0
class Post(app.db.Model):
    __tablename__ = "posts"

    id = orm.Integer(primary_key=True)
    author = orm.ForeignKey(User)
    timestamp = orm.DateTime()
    content = orm.Text()

    @property
    def post_time(self):
        from datetime import datetime

        return datetime.strptime(self.timestamp, "%Y-%m-%d %H:%M:%S.%f")
Exemplo n.º 22
0
 class VAR_SEQ(orm.Model):
     __tablename__ = 'VAR_SEQ'
     __metadata__ = self.metadata
     __database__ = self.database
     ftId = orm.String(max_length=100,
                       primary_key=True,
                       allow_blank=True)
     Entry = orm.String(max_length=50, primary_key=True)
     # AltRange = orm.JSON(allow_null=True)
     begin = orm.Integer(allow_null=True)
     end = orm.Integer(allow_null=True)
     # AltInfo = orm.Text(allow_null=True, allow_blank=True)
     before = orm.Text(allow_null=True, allow_blank=True)
     after = orm.Text(allow_null=True, allow_blank=True)
     # AltIso
     description = orm.String(max_length=100,
                              allow_blank=True,
                              allow_null=True)
     # AltLen = orm.JSON(allow_null=True)
     before_len = orm.Integer(allow_null=True)
     after_len = orm.Integer(allow_null=True)
     evidence = orm.Text(allow_null=True, allow_blank=True)
Exemplo n.º 23
0
 class StatsChainSeq(orm.Model):
     __tablename__ = 'StatsChainSeq'
     __metadata__ = self.metadata
     __database__ = self.database
     pdb_id = orm.String(max_length=4, primary_key=True)
     entity_id = orm.Integer(primary_key=True)
     chain_id = orm.String(max_length=10)
     struct_asym_id = orm.String(max_length=10, primary_key=True)
     OBS_INDEX = orm.JSON()
     OBS_COUNT = orm.Integer()
     OBS_RATIO_ARRAY = orm.Text()
     BINDING_LIGAND_INDEX = orm.JSON()
     BINDING_LIGAND_COUNT = orm.Integer()
Exemplo n.º 24
0
class TodoList(orm.Model):

    __tablename__ = "todo"
    __database__ = database
    __metadata__ = metadata

    id = orm.Integer(primary_key=True)
    title = orm.String(max_length=30, allow_null=False)
    status = orm.Boolean(default=False)
    info = orm.Text()
    created_at = orm.DateTime()
    updated_at = orm.DateTime()
    deleted_at = orm.DateTime()
Exemplo n.º 25
0
 class ResidueMapping(orm.Model):
     __tablename__ = 'ResidueMapping'
     __metadata__ = self.metadata
     __database__ = self.database
     UniProt = orm.String(max_length=50, primary_key=True)
     author_insertion_code = orm.String(max_length=50,
                                        allow_null=True,
                                        allow_blank=True,
                                        default='')
     author_residue_number = orm.Integer()
     chain_id = orm.String(max_length=10)
     entity_id = orm.Integer(primary_key=True)
     identifier = orm.Text(allow_null=True,
                           allow_blank=True,
                           default='')
     name = orm.Text(allow_null=True, allow_blank=True, default='')
     observed = orm.String(max_length=1)
     pdb_id = orm.String(max_length=4, primary_key=True)
     pdb_one_letter_code = orm.String(max_length=1, primary_key=True)
     residue_number = orm.Integer(primary_key=True)
     struct_asym_id = orm.String(max_length=10, primary_key=True)
     unp_one_letter_code = orm.String(max_length=1, primary_key=True)
     unp_residue_number = orm.Integer(primary_key=True)
Exemplo n.º 26
0
class LitemallGoods(BaseModel):
    __tablename__ = 'litemall_goods'
    goods_sn = orm.String(length=63)
    name = orm.String(length=127)
    category_id = orm.Integer()
    brand_id = orm.Integer()
    gallery = orm.String(length=1023)
    keywords = orm.String(length=255)
    brief = orm.String(length=255)
    is_on_sale = orm.TinyInteger(length=1)
    sort_order = orm.Integer()
    pic_url = orm.String(length=255)
    unit = orm.String(length=31)
    retail_price = orm.Float()
    detail = orm.Text()
Exemplo n.º 27
0
 class ALTERNATIVE_PRODUCTS(orm.Model):
     __tablename__ = 'ALTERNATIVE_PRODUCTS'
     __metadata__ = self.metadata
     __database__ = self.database
     isoform = orm.String(max_length=50, primary_key=True)
     name = orm.JSON(allow_null=True)
     synonyms = orm.JSON(allow_null=True)
     sequenceStatus = orm.String(max_length=50)
     VAR_SEQ = orm.JSON(allow_null=True)
     accession = orm.String(max_length=50, primary_key=True)
     else_iso = orm.JSON(allow_null=True)
     iso_range = orm.JSON(allow_null=True)
     iso_range_len = orm.Integer(allow_null=True)
     sequence = orm.Text(allow_null=True)
     length = orm.Integer(allow_null=True)
Exemplo n.º 28
0
class Product(orm.Model):
    registry = models
    fields = {
        "id": orm.Integer(primary_key=True),
        "uuid": orm.UUID(allow_null=True),
        "created": orm.DateTime(default=datetime.datetime.now),
        "created_day": orm.Date(default=datetime.date.today),
        "created_time": orm.Time(default=time),
        "data": orm.JSON(default={}),
        "description": orm.Text(allow_blank=True),
        "huge_number": orm.BigInteger(default=0),
        "price": orm.Decimal(max_digits=5, decimal_places=2, allow_null=True),
        "status": orm.Enum(StatusEnum, default=StatusEnum.DRAFT),
        "value": orm.Float(allow_null=True),
    }
Exemplo n.º 29
0
 class StatsProteinEntitySeq(orm.Model):
     __tablename__ = 'StatsProteinEntitySeq'
     __metadata__ = self.metadata
     __database__ = self.database
     pdb_id = orm.String(max_length=4, primary_key=True)
     molecule_type = orm.Text()
     entity_id = orm.Integer(primary_key=True)
     ca_p_only = orm.Boolean()
     SEQRES_COUNT = orm.Integer()
     STD_INDEX = orm.JSON()
     STD_COUNT = orm.Integer()
     NON_INDEX = orm.JSON()
     NON_COUNT = orm.Integer()
     UNK_INDEX = orm.JSON()
     UNK_COUNT = orm.Integer()
     ARTIFACT_INDEX = orm.JSON()
Exemplo n.º 30
0
class Setting(orm.Model):
    __tablename__ = "setting"
    __database__ = database
    __metadata__ = metadata

    _id = orm.Integer(primary_key=True)
    config_id = orm.String(max_length=100)
    s_key = orm.String(max_length=100)
    s_value = orm.Text(default="")

    async def serialize(self, full=False):
        await self.load()
        return {
            "_id": self._id,
            "config_id": self.config_id,
            "s_key": jsonable_encoder(self.s_key),
            "s_value": jsonable_encoder(self.s_value),
        }