Skip to content

Commit b63ecd8

Browse files
committed
Resolve the merging conflicts
2 parents b15413e + e2aaadc commit b63ecd8

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

daiquiri/core/renderers/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def node(self, tag, attrs, text=''):
3838
attrs.update({'xsi:nil': 'true'})
3939

4040
self.xml.startElement(tag, {k: str(v) for k, v in attrs.items() if v is not None})
41-
if text:
41+
if text is not None:
4242
self.xml.characters(smart_str(text))
4343
self.xml.endElement(tag)
4444

daiquiri/files/utils.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from typing import Union
55
from urllib.parse import urljoin
66

7+
from django.apps import apps
78
from django.conf import settings
89
from django.shortcuts import render
910
from django.urls import reverse
@@ -13,7 +14,6 @@
1314
from django_sendfile import sendfile
1415

1516
from daiquiri.core.utils import get_client_ip, markdown
16-
from daiquiri.stats.models import Record
1717

1818
from .models import Directory
1919

@@ -91,14 +91,16 @@ def send_file(request, file_path, search=None):
9191

9292
absolute_file_path = os.path.join(settings.FILES_BASE_PATH, file_path)
9393

94-
Record.objects.create(
95-
time=now(),
96-
resource_type='FILE',
97-
resource=resource,
98-
client_ip=get_client_ip(request),
99-
user=request.user if request.user.is_authenticated else None,
100-
size=os.path.getsize(absolute_file_path),
101-
)
94+
if apps.is_installed('daiquiri.stats'):
95+
from daiquiri.stats.models import Record
96+
Record.objects.create(
97+
time=now(),
98+
resource_type='FILE',
99+
resource=resource,
100+
client_ip=get_client_ip(request),
101+
user=request.user if request.user.is_authenticated else None,
102+
size=os.path.getsize(absolute_file_path)
103+
)
102104

103105
# send the file to the client
104106
return sendfile(request, absolute_file_path)

0 commit comments

Comments
 (0)