Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conversion in update view if days are hidden #6

Open
hoffmka opened this issue Jul 13, 2020 · 2 comments
Open

conversion in update view if days are hidden #6

hoffmka opened this issue Jul 13, 2020 · 2 comments

Comments

@hoffmka
Copy link

hoffmka commented Jul 13, 2020

Many thanks for this nice app!
But I have discovered the following issue.
I need the duration in hours and minutes. Therefore I hide days and seconds in my Create- and UpdateView. If I create a duration e.g. with 100 hours, everything works fine. But If I want to update the 100 hours then the widget shows only "4" in the hours field (because 100 hours are 4 days and 4 hours).
Could you cancel the conversion if days are hidden? Maybe also for hours and minutes. Then it would be generic.

Thanks a lot!
Katja

@hoffmka
Copy link
Author

hoffmka commented Jul 29, 2020

For my use case I adjusted this function. It works fine for me. Many thanks for your work!!!

def decompress(self, value):
    if value:
        parsed_value = parse_duration(value)
        days, hours, minutes, seconds = get_time_factors(parsed_value)
        return_list = []
        return_list.append(days) if self.show_days else None
        if not self.show_days:
            return_list.append(days * 24 + hours) if self.show_hours else None
        else:
            return_list.append(hours) if self.show_hours else None
        return_list.append(minutes) if self.show_minutes else None
        return_list.append(seconds) if self.show_seconds else None
        return return_list
    else:
        return []

@devangpadhiyar
Copy link
Owner

Thanks for pulling it up. Let me check it out. If possible then can you fork it and generate a pull request for me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants