Modelling Quasi-Periodic Pulsations in Solar and Stellar Flares