Exemplo n.º 1
0
class Audit(models.Model):
    audit_id = models.AutoField(primary_key=True)
    organization = models.ForeignKey(to='organization.Organization',
                                     on_delete=models.CASCADE,
                                     blank=False,
                                     null=False,
                                     default=0)
    inventory_items = models.ManyToManyField(Item, blank=True, default=0)
    assigned_sk = models.ManyToManyField(to='user_account.CustomUser',
                                         blank=True,
                                         default=0)
    initiated_by = models.ForeignKey(to=USER_MODEL,
                                     on_delete=models.CASCADE,
                                     related_name='initiated_by')
    initiated_on = models.DateTimeField(
        auto_now_add=True)  # Auto set when object is first created
    last_modified_on = models.DateTimeField(
        auto_now=True)  # Auto set every time object is saved
    assigned_sk = models.ManyToManyField(to=USER_MODEL, blank=True, default=0)
    template_id = models.ForeignKey(AuditTemplate,
                                    on_delete=models.CASCADE,
                                    blank=True,
                                    null=True)
    accuracy = models.FloatField(default=0.0)

    ACTIVE = 'Active'

    AUDIT_STATUS = [(PENDING, 'Pending'), (COMPLETE, 'Complete'),
                    (ACTIVE, 'Active')]
    status = models.CharField(max_length=12,
                              choices=AUDIT_STATUS,
                              default=PENDING)
Exemplo n.º 2
0
class Project(models.Model):
    id = models.AutoField(primary_key=True)
    project_lead = models.ForeignKey(UserProfile,
                                     on_delete=models.CASCADE,
                                     null=True)
    preview = models.BooleanField(
        default=True
    )  # project will only appear in Project List when set to False

    # UI properties
    title = models.CharField(max_length=454, null=True)
    summary = models.CharField(max_length=254)
    skills_needed = models.ManyToManyField(Skill)
    learning_opportunities = models.ManyToManyField(Goal)
    civic_interests = models.ManyToManyField(Interest)
    pending_tasks = models.CharField(max_length=454, null=True)
    progress_made = models.CharField(max_length=454, null=True)
    additional_info = models.CharField(max_length=454, null=True)
    slack_channel = models.CharField(max_length=200)

    # Admin properties
    github_repository = models.CharField(max_length=454, null=True)
    website = models.CharField(max_length=454, null=True)
    twitter = models.CharField(max_length=454, null=True)

    def save(self, *args, **kwargs):
        super(Project, self).save(*args, **kwargs)

    def __str__(self):
        return self.title
Exemplo n.º 3
0
class Order(models.Model):
    OPTION = (
        ('Pending', 'Pending'),
        ('Out for delivery', 'Out for delivery'),
        ('Delivered', 'Delivered'),
        ('Canceled', 'Canceled'),
    )
    orderitems = models.ManyToManyField(Cart)
    customer = models.ForeignKey(Customer, null=True, on_delete=models.CASCADE)
    address = models.ManyToManyField(BillingAddress)
    ordered = models.BooleanField(default=False)
    status = models.CharField(
        max_length=200, null=True, choices=OPTION, default=OPTION[0][0])
    paymentId = models.CharField(max_length=200, null=True)
    date_created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return f'Order from {self.customer.first_name} {self.customer.last_name}  Phone: {self.customer.phone}'

    def getOrder_total(self):
        total = 0
        for order_item in self.orderitems.all():
            total += order_item.getCart_total()

        return total
Exemplo n.º 4
0
 def __enter__(self):
     self._old_au_local_m2m = AbstractUser._meta.local_many_to_many
     self._old_pm_local_m2m = PermissionsMixin._meta.local_many_to_many
     groups = models.ManyToManyField(Group, blank=True)
     groups.contribute_to_class(PermissionsMixin, "groups")
     user_permissions = models.ManyToManyField(Permission, blank=True)
     user_permissions.contribute_to_class(PermissionsMixin,
                                          "user_permissions")
     PermissionsMixin._meta.local_many_to_many = [groups, user_permissions]
     AbstractUser._meta.local_many_to_many = [groups, user_permissions]
Exemplo n.º 5
0
class Audit(models.Model):
    audit_id = models.AutoField(primary_key=True)
    organization = models.ForeignKey(Organization,
                                     on_delete=models.CASCADE,
                                     blank=False,
                                     null=False,
                                     default=0)
    status = models.CharField(max_length=50, default="Pending")
    inventory_items = models.ManyToManyField(Item, blank=True, default=0)
    assigned_sk = models.ManyToManyField(CustomUser, blank=True, default=0)
Exemplo n.º 6
0
class Recipe(models.Model):
    """Recipe object"""
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    title = models.CharField(max_length=255)
    time_minutes = models.IntegerField()
    price = models.DecimalField(max_digits=5, decimal_places=2)
    link = models.CharField(max_length=255, blank=True)
    ingredients = models.ManyToManyField('Ingredient')
    tags = models.ManyToManyField('Tag')

    def __str__(self):
        return self.title
Exemplo n.º 7
0
class StateSave(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=200, null=True)
    description = models.CharField(max_length=400, null=True)
    save_time = models.DateTimeField(auto_now=True, db_index=True)
    create_time = models.DateTimeField(auto_now_add=True)
    save_id = models.UUIDField(default=uuid.uuid4)
    data_dump = models.TextField(null=False)
    shared = models.BooleanField(default=False)
    owner = models.ForeignKey(get_user_model(),
                              null=True,
                              on_delete=models.CASCADE)
    base64_image = models.ImageField(upload_to='circuit_images',
                                     storage=file_storage,
                                     null=True)
    version = models.CharField(max_length=20, null=False)
    branch = models.CharField(max_length=20, null=False)
    is_arduino = models.BooleanField(default=False, null=False)
    esim_libraries = models.ManyToManyField(Library)
    project = models.ForeignKey(to=Project,
                                on_delete=models.SET_NULL,
                                null=True)

    def save(self, *args, **kwargs):
        super(StateSave, self).save(*args, **kwargs)

    def __str__(self):
        return self.name
Exemplo n.º 8
0
class Variation(models.Model):
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
    name = models.CharField(max_length=100)
    creator = models.ForeignKey(get_user_model(), on_delete=models.CASCADE)
    composition = models.ForeignKey(Composition, on_delete=models.CASCADE)
    tracks = models.ManyToManyField(
        Track,
        through='TrackInVariation',
    )

    def copy_variation(self, variation):
        self.name = variation.name
        self.creator = variation.creator
        self.composition = variation.composition
        self.tracks.set(variation.tracks)

    def save(self, *args, **kwargs):
        user = kwargs.pop('user')
        composition_id = kwargs.pop('composition_id')
        self.creator = user
        self.composition = Composition.objects.get(id=composition_id)
        super().save(*args, **kwargs)


#    def __str__(self):
#       return self.name + ' (' + str(self.composition) + ') - ' + self.creator.username
Exemplo n.º 9
0
class Entry(models.Model):
    blog = models.ForeignKey(Blog, on_delete=models.CASCADE)
    headline = models.CharField(max_length=255)
    authors = models.ManyToManyField(Author)

    def __str__(self):
        return self.headline
Exemplo n.º 10
0
class Order(models.Model):
    user = models.ForeignKey(settings.AUTH_USER_MODEL,
                             on_delete=models.CASCADE)
    ref_code = models.CharField(max_length=20, blank=True, null=True)
    products = models.ManyToManyField(OrderItem, blank=True)
    start_date = models.DateTimeField(auto_now_add=True)
    ordered_date = models.DateTimeField()
    ordered = models.BooleanField(default=False)
    shipping_address = models.ForeignKey('Address',
                                         related_name='shipping_address',
                                         on_delete=models.CASCADE,
                                         default=None)
    billing_address = models.ForeignKey('Address',
                                        related_name='billing_address',
                                        on_delete=models.CASCADE,
                                        default=None)
    payment = models.ForeignKey('Payment',
                                on_delete=models.CASCADE,
                                default=None)
    being_delivered = models.BooleanField(default=False)
    received = models.BooleanField(default=False)

    def __str__(self):
        return self.user.username

    def get_total(self):
        total = 0
        for order_item in self.products.all():
            total += order_item.get_final_price()

        return total
Exemplo n.º 11
0
class Gallery(models.Model):
    id = models.AutoField(primary_key=True)
    save_id = models.CharField(unique=True, max_length=500, null=False)
    data_dump = models.TextField(null=False)
    name = models.CharField(max_length=100, default="Untitled")
    description = models.CharField(max_length=1000)
    media = models.ImageField(upload_to='circuit_images_esim',
                              storage=file_storage,
                              null=True)
    shared = models.BooleanField(default=True)
    save_time = models.DateTimeField(auto_now=True)
    is_arduino = models.BooleanField(default=False, null=False)
    esim_libraries = models.ManyToManyField(Library)

    # For Django Admin Panel
    def image_tag(self):
        print(file_storage)
        if self.media:
            return mark_safe(
                '<img src="%s" style="width: 45px; height:45px;" />' %
                self.media.url)  # noqa
        else:
            return 'No Image Found'

    image_tag.short_description = 'Image'

    def __str__(self):
        return self.name
Exemplo n.º 12
0
class Postt(models.Model):
    title = models.CharField(max_length=200, verbose_name="titulo")
    content = models.TextField(verbose_name="Contenido")
    published = models.DateTimeField(verbose_name="fecha de publicacion",
                                     default=now)
    image = models.ImageField(verbose_name="imagen",
                              upload_to="blog",
                              null=True,
                              blank=True)
    author = models.ForeignKey(User,
                               verbose_name="Autor",
                               on_delete=models.CASCADE)
    categories = models.ManyToManyField(Category,
                                        verbose_name="Categorias",
                                        related_name="get_posts")
    created = models.DateTimeField(auto_now_add=True,
                                   verbose_name="Fecha de creacion")
    update = models.DateTimeField(auto_now=True,
                                  verbose_name="Fecha de actualizacion")

    class Meta:
        verbose_name = "post"
        verbose_name_plural = "posts"
        ordering = ['-created']

    def __str__(self):
        return self.title
Exemplo n.º 13
0
class Post(models.Model):
    id = models.AutoField(primary_key=True)
    category = models.ForeignKey(Category,
                                 on_delete=models.CASCADE,
                                 related_name='posts')
    title = models.CharField(max_length=255)
    # title_vn = models.CharField(max_length=255)
    content = models.TextField()
    # content_vn = models.TextField()
    created_at = models.DateTimeField(auto_now_add=True)
    update_at = models.DateTimeField(auto_now=True)
    thumbnail = models.TextField(null=True)
    author = models.ForeignKey(get_user_model(),
                               on_delete=models.CASCADE,
                               related_name='posts',
                               default=1)
    author_username = models.CharField(max_length=100, default="admin")
    # publish = models.DateTimeField(auto_now=False, auto_now_add=False)
    likes = models.ManyToManyField(get_user_model())
    objects = models.DjongoManager()
    hidden = models.BooleanField(default=False)
    flag = models.BooleanField(default=False)

    def __str__(self):
        return f'{self.title}'
Exemplo n.º 14
0
class TestUUIDM2M(models.Model):
    id = models.UUIDField(primary_key=True,
                          unique=True,
                          editable=False,
                          default=uuid.uuid4)
    name = models.CharField(max_length=50)
    test_m2m = models.ManyToManyField(TestUUIDModel)
Exemplo n.º 15
0
class RelacaoAbono(models.Model):

    objects = models.Manager()
    abonos = models.ManyToManyField(Abono, blank=True)
    data_inicio = models.DateTimeField()
    data_termino = models.DateTimeField()

    class Meta:
        verbose_name = 'Relação de abonos'
        verbose_name_plural = "Relações de abonos"
        ordering = ['-data_inicio']
        

    @staticmethod
    def factory(data_inicio, data_termino):
        abonos = Abono.objects.filter(
            Q(deferido=True)
            & Q(criado_em__gte=data_inicio)
            & Q(criado_em__lte=data_termino)
        )      
        relacao = RelacaoAbono.objects.create(
            data_inicio=data_inicio,
            data_termino=data_termino
        )
        for abono in abonos:
            relacao.abonos.add(abono)

        relacao.save()
        return relacao
Exemplo n.º 16
0
class Assembly(models.Model):
    id = models.CharField(primary_key=True, max_length=100)
    sequences = models.ManyToManyField(to=Sequence,
                                       related_name='assemblies',
                                       blank=True)
    biosample = models.ForeignKey(BioSample,
                                  related_name="assemblies",
                                  on_delete=models.CASCADE,
                                  null=True)

    count = models.IntegerField(null=True, blank=True)
    bp = models.IntegerField(null=True, blank=True)
    Ns = models.IntegerField(null=True, blank=True)
    gaps = models.IntegerField(null=True, blank=True)
    min = models.IntegerField(null=True, blank=True)
    max = models.IntegerField(null=True, blank=True)
    avg = models.IntegerField(null=True, blank=True)
    N50 = models.IntegerField(null=True, blank=True)

    owner = models.ForeignKey(Account,
                              related_name="genomes",
                              on_delete=models.CASCADE)
    DateCreated = models.DateTimeField(verbose_name='date created',
                                       auto_now=True)
    LastUpdate = models.DateTimeField(verbose_name='last update',
                                      auto_now=True)

    description = models.TextField(null=True, blank=True)

    objects = models.DjongoManager()

    def __str__(self):
        return str(self.id)
Exemplo n.º 17
0
class Series(models.Model):
    series_name = models.CharField(max_length=255)
    series_poster = models.URLField()  #! Should be image field
    genre = models.ManyToManyField(Genre)
    description = models.CharField(max_length=255)
    trailer_link = models.URLField()  #! Should be file field
    cast = models.ArrayField(model_container=Cast, )
    language = models.ManyToManyField(Language, )
    aired = models.DateField()
    rating_info = models.IntegerField()
    production_Company = models.CharField(max_length=255)
    gallery = models.ManyToManyField(Gallery, )

    objects = models.DjongoManager()

    def __str__(self):
        return self.series_name
Exemplo n.º 18
0
class Link(models.Model):
    users = models.ManyToManyField(User)
    url = models.CharField(max_length=200, null=True)
    content = models.TextField(default='')
    is_multi_page = models.BooleanField()
    page_id = models.CharField(max_length=50, null=True)
    next_check = models.FloatField(default=0)
    penalty = models.FloatField(default=10)
    version = models.IntegerField(default=0)
Exemplo n.º 19
0
class Post(models.Model):
    _id = models.ObjectIdField()
    id_instagram_commented_post = models.CharField(max_length=255)
    created_date = models.DateTimeField(
        auto_now_add=True, blank=True)  # Created date added by itself
    words = models.ManyToManyField(Word)

    def __str__(self):
        return self.id_instagram_commented_post
class Science_Group(models.Model):
    group_id = models.IntegerField(unique=True)
    group_purpose = models.CharField(max_length=300)
    teacher = models.ForeignKey(Teacher, on_delete=models.CASCADE)
    student = models.ManyToManyField(Student)

    def __str__(self):
        return 'Науч. группа №{}, руководитель - {}, назначение - {}'.format(
            str(self.group_id), self.teacher, self.group_purpose)
Exemplo n.º 21
0
class Pack(models.Model):
    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    order = models.ForeignKey(Order, on_delete=models.CASCADE)
    model = models.ManyToManyField(VehicleModel)
    price = models.FloatField()
    quantity = models.IntegerField(default=0)

    def __str__(self):
        return self.model.vehiclemodel.brand
Exemplo n.º 22
0
class Book(models.Model):
    title = models.CharField(max_length=100, null=False, blank=False)
    content = models.EmbeddedModelField(
        model_container=BookContent,
    )
    authors = models.ManyToManyField(Author)

    def __str__(self):
        return self.title
Exemplo n.º 23
0
class RelationContainerModel(models.Model):
    _id = models.ObjectIdField()
    control_val = models.CharField(default='CONTROL', max_length=10)
    fk_field = models.ForeignKey(to=ForeignKeyRelatedModel,
                                 on_delete=models.CASCADE)
    mtm_field = models.ManyToManyField(to=ManyToManyRelatedModel,
                                       blank=True,
                                       related_name='container_field')

    objects = models.DjongoManager()
Exemplo n.º 24
0
class Blog(models.Model):
    Title = models.CharField(max_length=100)
    Content = models.TextField()
    Category = models.ManyToManyField(Category)
    DatePosted = models.DateTimeField(default=timezone.now)
    Creator = models.ForeignKey(User, on_delete=models.CASCADE)
    sentiment = models.BooleanField(default=1)

    def __str__(self):
        return self.Title
Exemplo n.º 25
0
class Tag(models.Model):
    """
    class to define the data model of the tags in the DB.
    """
    tag = models.CharField(max_length=200, blank=True, null=True)
    organizations = models.ManyToManyField(
        OrganizationProfile, blank=True, related_name='tagsAndKeywords')

    def __str__(self):
        return self.tag
Exemplo n.º 26
0
class CallTag(models.Model):
    """
    class to define the data model of the EU calls tags.
    """
    tag = models.CharField(max_length=200, blank=True, null=True)
    calls = models.ManyToManyField(
        Call, blank=True, related_name='tagsAndKeywords')

    def __str__(self):
        return self.tag
Exemplo n.º 27
0
class Movie(models.Model):
    movie_name = models.CharField(max_length=255)
    movie_poster = models.URLField()  #! Should use image field
    genre = models.ManyToManyField(Genre)
    description = models.CharField(max_length=255)
    trailer_link = models.URLField()  #! Should use File filed
    movie_link = models.URLField()  #! Should use File field
    movie_length = models.TimeField()
    cast = models.ArrayField(
        model_container=Cast)  #? Don't now if array field work for image.
    language = models.ManyToManyField(Language)
    aired = models.DateField()
    review_ID = models.IntegerField()
    rating_info = models.FloatField()
    production_Company = models.CharField(max_length=255)
    gallery = models.ManyToManyField(Gallery)

    objects = models.DjongoManager()

    def __str__(self):
        return self.movie_name
Exemplo n.º 28
0
class Team(models.Model):
    select_team = (
        ('Red', 'Red'),
        ('Blue', 'Blue'),
        ('White', 'White'),
    )

    team = models.CharField(max_length=5, choices=select_team)
    players = models.ManyToManyField(User)

    def __str__(self):
        return self.team
Exemplo n.º 29
0
class Announcement(models.Model):
    topic = models.CharField(max_length=50)
    slug = models.SlugField(unique=True)
    author = models.ForeignKey(User, related_name='aut',
                               on_delete=models.CASCADE)
    data = models.DateTimeField(auto_now_add=True)
    text_of_announcement = models.TextField()
    tags = models.ManyToManyField(Tag, blank=True,
                                  related_name='announcement')

    def __str__(self):
        return self.topic
Exemplo n.º 30
0
class Event(models.Model):
    """
        Event Object which contains Event name, url and if the event is up coming or from the past
    """
    event_name = models.CharField(max_length=200, unique=True)
    event_url = models.CharField(max_length=200)
    event_date = models.DateField(blank=True, null=True)
    is_upcoming = models.BooleanField(default=False, null=True)
    event_part = models.ManyToManyField(Participants, blank=True, related_name='Part_Event')

    def __str__(self):
        return self.event_name