tuttle-dev / tuttle

🪰 Tuttle - time and money management for freelancers
GNU General Public License v3.0
62 stars 12 forks source link

Bug: Implementing is active on Contract, and Project models #134

Closed vlad-ed-git closed 1 year ago

vlad-ed-git commented 1 year ago

@clstaudt Contract model's implementation of the is_active method throws this error '>' not supported between instances of 'NoneType' and 'datetime.date'

clstaudt commented 1 year ago

@vlad-ed-git Okay, will have a look. Full stack trace for bug reports please.

vlad-ed-git commented 1 year ago

Getting 'list' object has no attribute 'where', from the contracts' data source. @clstaudt

clstaudt commented 1 year ago

Copy/paste the complete Python interpreter stack trace please 😄

vlad-ed-git commented 1 year ago

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/Users/vlad/Desktop/vlad/tuttle/app/contracts/view.py", line 561, in on_click=lambda e: onClick(state), File "/Users/vlad/Desktop/vlad/tuttle/app/contracts/view.py", line 583, in on_filter_button_clicked self.onStateChangedCallback(state) File "/Users/vlad/Desktop/vlad/tuttle/app/contracts/view.py", line 1075, in on_filter_contracts self.contracts_to_display = self.intent_handler.get_active_contracts() File "/Users/vlad/Desktop/vlad/tuttle/app/contracts/intent.py", line 112, in get_active_contracts if c.is_active(): File "/Users/vlad/Desktop/vlad/tuttle/tuttle/model.py", line 305, in is_active return self.end_date > today TypeError: '>' not supported between instances of 'NoneType' and 'datetime.date'

vlad-ed-git commented 1 year ago

self.intent_handler.get_active_contracts() calls is_active() on each contract model and that's where an error occurs.

clstaudt commented 1 year ago

Contract: possible quick fix (can't code on iPad unfortunately) @vlad-ed-git

def is_active(self) -> bool:
    if self.end_date:
        today = datetime.date.today()
        return self.end_date > today
    else:
        return True
clstaudt commented 1 year ago

Project.end_date cannot be None according to the model definition. So there is no bug in Project.is_active

vlad-ed-git commented 1 year ago

Okay I will add this

On Friday, January 13, 2023, Christian Staudt @.***> wrote:

Project.end_date cannot be none as per the model definition. So there is no bug in Project.is_active

— Reply to this email directly, view it on GitHub https://github.com/tuttle-dev/tuttle/issues/134#issuecomment-1381489114, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJGBW67RGCIJFSVNZ3QOSBLWSEI4ZANCNFSM6AAAAAATZEVX7A . You are receiving this because you were mentioned.Message ID: @.***>

vlad-ed-git commented 1 year ago

@clstaudt fixed