def delete_feedback(pk): try: fb = HandledFeedback.objects.get(pk=pk) fb.delete() except Exception as e: logger.exception(e) transaction.roll_back() raise e else: transaction.commit()
def add_ad(ad): try: ad.save() if ad.visible: _set_ad_visible(ad.pk) else: ad.position = _MAX_ADS ad.save() except Exception as e: logger.exception(e) transaction.roll_back() raise e else: transaction.commit()
def sort_ad(pks): try: AD.objects.exclude(pk__in=pks).update(position=_MAX_ADS, visible=False) AD.objects.filter(pk__in=pks).update(visible=True) for i in range(0, len(pks)): ad = AD.objects.get(pk=pks[i]) ad.position = i + 1 ad.save() except Exception as e: logger.exception(e) transaction.roll_back() raise e else: transaction.commit()
def delete_ad(pk): try: ad = AD.objects.get(pk=pk) if not ad.visible: ad.delete() else: _set_ad_invisible(pk) delete_ad(pk) except Exception as e: logger.exception(e) transaction.roll_back() raise e else: transaction.commit()
def edit_ad(ad): visible = ad.visible visible_changed = AD.objects.get(pk=ad.pk).visible != ad.visible try: ad.save() if visible_changed: if visible: _set_ad_visible(ad.pk) else: _set_ad_invisible(ad.pk) except Exception as e: logger.exception(e) transaction.roll_back() raise e else: transaction.commit()