Skip to main content

Abstract countdown timer model to use in your Django projects.

Project description

About

The goal of this library is to allow you to inherit an abstract model in your model and turn it into a countdown time with pause and resume capability.

Simply import, inherit and your model is now a timer without worrying about the complexity involved in timekeeping.

This library is written to return the countdown value based on timestamps and thus does not require complicated background tick processes.

Minimum Requirements

  • Python 3.7

  • Django 3.0.5

Installation

Run the following in your project.

pip install django-countdowntimer-model

In your settings.p file please add:

INSTALLED_APPS = [
    # ...
    "countdowntimer_model",
    # ...
]

Usage

First you must import the abstraction into your model file.

from countdowntimer_model.models import CountdownTimer

Afterwords your model must inherit the abstraction.

class DoomsdayCountdownTimer(CountdownTimer):
    # ...

When you create your model, it is essential you set the duration_in_minutes and state fields. Afterwords the model will handle the rest. Please note if you want to override to use a custom timezone then you can set the timezone_override field.

doomsday_timer = DoomsdayCountdownTimer.object.create(
    duration_in_minutes=123,
    state=DoomsdayCountdownTimer.STATE.RUNNING,
)

Now that the object has been created you can get the latest countdown by running the following:

remaining_t = doomsday_timer.remaining_time() # // Returned in `time` format.

or

remaining_minutes = doomsday_timer.remaining_time_in_minutes() # // Returned in `integer` format.

License

This library is licensed under the BSD 2-Clause License. See LICENSE for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-countdowntimer-model-0.0.6.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django-countdowntimer-model-0.0.6.tar.gz.

File metadata

  • Download URL: django-countdowntimer-model-0.0.6.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for django-countdowntimer-model-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f5ecb73f9bf58065f42159809fa9f111fbe2359d59d9795239f707a931d0b356
MD5 9805cda7d6392ab404ccec7176829690
BLAKE2b-256 99e40691d2b4a117632a8927c62b80aaeea05e66a19606f0f6a7fff83d95d3ba

See more details on using hashes here.

Provenance

File details

Details for the file django_countdowntimer_model-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: django_countdowntimer_model-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for django_countdowntimer_model-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 ea2d4955062a95e56ed009f9d882489484a0a8f2020623537a27cb2fccc05ec4
MD5 bb9257c9c51026ebda5b0fb46ccf94ad
BLAKE2b-256 e3b4886942b33a3a964e98c7473bef25910f603d766648a78d8fbcd484441088

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page