Blingo
- Connecting to the ocean
+
+ Connecting people to our blue planet through positive actions
+
diff --git a/documentation/docs/img/exporting.png b/documentation/docs/img/exporting.png
new file mode 100644
index 0000000..e25c8bb
Binary files /dev/null and b/documentation/docs/img/exporting.png differ
diff --git a/documentation/docs/staff.md b/documentation/docs/staff.md
index aff1f39..d1402f6 100644
--- a/documentation/docs/staff.md
+++ b/documentation/docs/staff.md
@@ -97,3 +97,11 @@ If you just want to see the submissions of a particular user, this can be done f
If you wish to revoke a user's submission, you can do so by pressing the delete button. The submission will then no longer be visible in the user's profile page. Alternatively, if you just wish to delete the image the user uploaded, then you can mark the "Clear" checkbox within the image field and press the "Save" button.

+
+## Exporting
+
+The admin dashboard provides the option to export its data into CSV format. To do this, navigate to the database table you wish to export (the screenshot below shows the User table). Mark the checkbox in the top left to select all the rows (you can also select a subset of the rows if you prefer). Then select "Export selected objects as CSV" from the dropdown and press "Go". This will download a CSV file containing all the relevant data for the table you are viewing.
+
+
+
+Note that staff users are not included in the CSV file resulting from exporting the User table.
diff --git a/server/bingo/actions.py b/server/bingo/actions.py
index 67ae097..a218ca4 100644
--- a/server/bingo/actions.py
+++ b/server/bingo/actions.py
@@ -1,5 +1,6 @@
from django.http import HttpResponse
from django.contrib.admin import action
+from django.db.models import ForeignKey
from .models import User, TileInteraction
@@ -7,8 +8,10 @@ def get_friendly_value(instance, field_name, value):
display_method = f'get_{field_name}_display'
if hasattr(instance, display_method):
return getattr(instance, display_method)()
+ elif isinstance(field := type(instance)._meta.get_field(field_name), ForeignKey):
+ return str(field.related_model.objects.get(pk=value))
else:
- # If it's not a choice field, return the raw value
+ # If it's not a choice field or a foreign key, return the raw value
return value