Ejemplo n.º 1
0
class Task(db.EmbeddedDocument):
    title = db.StringField(verbose_name="Title",
                           max_length=255,
                           unique=True,
                           required=True)
    details = db.StringField(verbose_name="Details")
    setdate = db.DateTimeField(default=datetime.datetime.now)
    lastdate = db.DateTimeField(verbose_name="Last Date")
    completed = db.BooleanField(default=False)
    url = db.StringField(max_length=255, unique=True)
Ejemplo n.º 2
0
class Transaction(db.Document):
    """
    A class used to represent the transaction model
    ...

    Attributes
    ----------
    customer_ref_id : reference
        a reference field to the customer
    amount : float
        the transaction amount
    interest : float
        the interest applied to the amount
    total_amount: float
        the total_amount
    description : str
        the description of the transaction
    transaction_name: str
        the name of transaction
    user_ref_id: reference
        user reference ID
    store_ref_id: reference
        store reference ID

    Methods
    -------
    pre_save(cls, sender, transaction, *kw)
        handles time attribute(updated_at) ONLY when transaction is modified
    """

    customer_ref_id = db.ReferenceField(customer.Customer,
                                        required=True,
                                        dbref=True)
    amount = db.FloatField(required=True)
    interest = db.FloatField(required=True)
    total_amount = db.FloatField(required=True)
    description = db.StringField(required=True)
    transaction_name = db.StringField(required=True)
    transaction_role = db.StringField(required=True)
    user_ref_id = db.ReferenceField(user.User, dbref=True, required=True)
    #store_ref_id = db.ReferenceField(user_store.Store, dbref=True, required=True)
    store_ref_id = db.ReferenceField(store.Store, dbref=True, required=True)
    created_at = db.DateTimeField(default=datetime.datetime.utcnow)
    updated_at = db.DateTimeField(default=datetime.datetime.utcnow)

    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        document.updated_at = datetime.datetime.utcnow()

    def __str__(self):
        return "<Transaction Details: {}-{} by {} at {}>".format(
            self.transaction_name, self.transaction_role, self.user_ref_id,
            self.created_at)
Ejemplo n.º 3
0
class Project(db.Document):
    project = db.StringField(verbose_name="Project",
                             max_length=255,
                             unique=True,
                             required=True)
    description = db.StringField(verbose_name="Description")
    dateofcreation = db.DateTimeField(default=datetime.datetime.now)
    url = db.StringField(max_length=255, unique=True, required=True)
    tasks = db.ListField(db.EmbeddedDocumentField('Task'))

    @property
    def completed(self):
        projectDetails = Project.objects().get(url=self.url)
        count = 0
        for i in projectDetails.tasks:
            if i.completed == True:
                count += 1
        return count

    @property
    def remaining(self):
        projectDetails = Project.objects().get(url=self.url)
        count = 0
        for i in projectDetails.tasks:
            if i.completed == False:
                count += 1
        return count
Ejemplo n.º 4
0
class DebtReminder:
    ts_ref_id = db.ReferenceField(transaction.Transaction,
                                  dbref=True,
                                  required=True)
    message = db.StringField(required=True)
    status = db.StringField(required=True)
    expected_pay_date = db.DateTimeField(default=datetime.datetime.utcnow)
    updated_at = db.DateTimeField(default=datetime.datetime.utcnow)

    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        document.updated_at = datetime.datetime.utcnow()

    def __str__(self):
        return "<Debt Reminder: {}; {} at {}>".format(self.ts_ref_id,
                                                      self.message,
                                                      self.expected_pay_date)
Ejemplo n.º 5
0
class Store(db.Document):
    store_name = db.StringField(required=True, unique=True)
    Phone_number = db.StringField(required=True)
    tagline = db.StringField(required=True)
    shop_address = db.StringField(required=True)
    email = db.StringField(unique=True)
    created = db.DateTimeField(default=datetime.datetime.utcnow)

    def __str__(self):
        return "<Store: {}>".format(self.store_name)
Ejemplo n.º 6
0
class Complaint(db.Document):
    user_ref_id = db.ReferenceField(user.User, required=True)
    message = db.StringField(required=True)
    store_ref_code = db.ReferenceField(user_store.UserStore, required=True)
    status = db.StringField(default="open")
    timestamp = db.DateTimeField(default=datetime.datetime.utcnow)

    def __repr__(self):
        return "<Complaint: from: {}; opened: {}>".format(
            self.store_ref_code, self.timestamp)
Ejemplo n.º 7
0
class User(db.Document):
    phone_number = db.StringField(required=True, unique=True)
    first_name = db.StringField(required=True)
    last_name = db.StringField(required=True)
    email = db.StringField(required=True, unique=True)
    is_active = db.BooleanField(default=False)
    password = db.StringField(required=True)
    api_token = db.StringField()
    user_role = db.StringField(default="store_admin")
    reg_date = db.DateTimeField(default=datetime.datetime.utcnow)

    def __str__(self):
        return "<User: {}>".format(self.first_name)
Ejemplo n.º 8
0
class Customer(db.Document):
    """
    A class used to represent the customer model
    ...

    Attributes
    ----------
    store_ref_id: reference
        store reference ID
    name : str
        the name of the customer
    phone_number: str
        the phone number of the customer
    created_at: datetime str
        time when customer is created
    updated_at: datetime str
        time when customer is modified

    Methods
    -------
    pre_save(cls, sender, customer, *kw)
        handles time attribute(updated_at) ONLY when customer detail is modified
    """

    store_ref_id = db.ReferenceField(store.Store, dbref=True, required=True)
    name = db.StringField(required=True)
    phone_number = db.StringField(required=True)
    created_at = db.DateTimeField(default=datetime.datetime.utcnow)
    updated_at = db.DateTimeField(default=datetime.datetime.utcnow)


    @classmethod
    def pre_save(cls, sender, document, **kwargs):
        document.updated_at = datetime.datetime.utcnow()

    def __str__(self):
        return "<Customer: {}; {} at {}>".format(self.name, self.store_ref_id, self.created_at)
Ejemplo n.º 9
0
class Post(db.Document):
    id = db.StringField(default=lambda: str(uuid.uuid4()), primary_key=True)
    title = db.StringField(max_length=255, required=True)
    slug = db.StringField(max_length=255, required=True, unique=True)
    date_posted = db.DateTimeField(default=datetime.datetime.now,
                                   required=True)
    content = db.StringField(required=True)
    author = db.ReferenceField(User, required=True)

    meta = {
        "allow_inheritance": False,
        "indexes": ["-date_posted", "slug", "title"],
        "ordering": ["-date_posted"],
        "collection": "posts",
    }
Ejemplo n.º 10
0
class Prediction(db.Document):
    meta = {'collection': 'predictions'}
    predictionResults = db.ListField(required=True)
    rawPredictionResults = db.ListField(required=True)
    date = db.DateTimeField(required=True)
Ejemplo n.º 11
0
class Feedback(db.Document):
    meta = {'collection': 'feedbacks'}
    content = db.EmbeddedDocumentListField('FeedbackContent', required=True)
    date = db.DateTimeField(required=True)