OUR EXPERT
Matt Holder is an IT professional of 15 years, Linux user for over 20 years, user of plenty of home automation gear, and self-professed geek.
OUR EXPERT
Matt Holder is an IT professional of 15 years, Linux user for over 20 years, user of plenty of home automation gear, and self-professed geek.
QUICK TIP
Full code for this tutorial can be downloaded from GitHub, using this link: https://github.com/mattmole/LXF 328-Coffee-Rewards/
QUICK TIP
Full code for this tutorial can be downloaded from GitHub, using this link: https://github.com/mattmole/LXF 328-Coffee-Rewards/
While standing in the queue at a local coffee shop, we wondered how hard it would be to replace the card-and-stamp reward system with something more modern. The brief was that it must be simple to use and perform the task easily.
The project began with the following spec. Reward accounts will be looked up via a unique alphanumeric string, which the customer can remember or hand to the café on a card. Customer data shouldn’t be stored as it can cause data protection issues. There needs to be three operations: adding points, converting points to rewards, and using rewards for free drinks. A timeline of account operations should be stored, as well as the current status and a total number of points rewarded since the account was opened.
The next decision to be made was that of which programming language and framework to use. We decided on Python and Django, which gives a web browser interface to the software. Django operates using an MVC paradigm – this stands for Model, View, Controller, where the Model describes how the data is stored, Views describe how the data is viewed and how the system is interacted with, and the Controller represents the program’s logic.
We will be using UV to provide a virtual environment for this project, which separates all dependencies from the operating system’s main installation of Python. Open your terminal and run the following commands: $ curl -LsSf https://astral.sh/uv/install.sh |
sh We now need to create the project, install dependencies and create our templated Django project. Head back to your terminal and run the following commands: $ uv init RewardSystem $ cd RewardSystem $ uv add django rich $ uv run django-admin startproject RewardSystem . $ rm hello.py $ uv run django-admin startapp Points $ uv run manage.py migrate $ uv run manage.py createsuperuser