Exemple #1
0
def toggle_payment(modeladmin, request: HttpRequest, queryset: QuerySet):  # pylint: disable=unused-argument
    for e in queryset:
        assert isinstance(e, EntryType)
        e.is_payment = not e.is_payment
        e.save()
        admin_log([e],
                  "Toggled payment flag {}".format(
                      "on" if e.is_settlement else "off"),
                  who=request.user)  # type: ignore
Exemple #2
0
def toggle_payment(modeladmin, request: HttpRequest, queryset: QuerySet):
    for e in queryset:
        assert isinstance(e, EntryType)
        e.is_payment = not e.is_payment
        e.save()
        admin_log([e],
                  'Toggled payment flag {}'.format(
                      'on' if e.is_settlement else 'off'),
                  who=request.user)
Exemple #3
0
 def save_account_entry_note(request, obj: AccountEntryNote):
     if not hasattr(obj, "created_by") or obj.created_by is None:
         obj.created_by = request.user
     else:
         old = AccountEntryNote.objects.all().filter(id=obj.id).first()
         if old is not None:
             assert isinstance(old, AccountEntryNote)
             if old.note != obj.note:
                 obj.created_by = request.user
                 admin_log(
                     [obj, obj.account_entry],
                     "Note id={} modified, previously: {}".format(
                         old.id, old.note),
                     who=request.user,
                 )
     obj.save()
Exemple #4
0
def resend_invoices(modeladmin, request: HttpRequest, queryset: QuerySet):  # pylint: disable=unused-argument
    """
    Marks invoices with as un-sent.
    :param modeladmin:
    :param request:
    :param queryset:
    :return:
    """
    user = request.user
    assert isinstance(user, User)
    for obj in queryset:
        assert isinstance(obj, Invoice)
        admin_log([obj, user],
                  "Invoice id={invoice} marked for re-sending".format(
                      invoice=obj.id),
                  who=user)
    queryset.update(sent=None)
Exemple #5
0
 def _set_default_paths(self, options: dict):
     default_path = os.path.abspath(options["path"])
     qs = PayoutStatus.objects.all().filter(file_path="")
     if options["ws"]:
         qs = qs.filter(payout__connection_id=options["ws"])
     objs = list(qs)
     print("Setting default path of {} status updates to {}".format(len(objs), strip_media_root(default_path)))
     for obj in objs:
         assert isinstance(obj, PayoutStatus)
         full_path = os.path.join(default_path, obj.file_name)
         if not os.path.isfile(full_path):
             msg = "Error while updating file path of PayoutStatus id={}: File {} not found".format(obj.id, full_path)
             if not options["ignore_errors"]:
                 raise Exception(msg)
             logger.error(msg)
             continue
         file_path = strip_media_root(full_path)
         logger.info('PayoutStatus.objects.filter(id=%s).update(file_path="%s")', obj.id, file_path)
         if not options["test"]:
             PayoutStatus.objects.filter(id=obj.id).update(file_path=file_path)
             admin_log([obj], 'File path set as "{}" from terminal (parse_xp)'.format(full_path))
     print("Done")