Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

View documents in new tab #31

Merged
merged 2 commits into from
Sep 18, 2024
Merged

Conversation

remyvdwereld
Copy link
Collaborator

No description provided.

@remyvdwereld remyvdwereld self-assigned this Sep 17, 2024
Comment on lines 1294 to 1314
qs = Case._default_manager.by_user(user=request.user)
case = qs.filter(pk=case_pk).first()
if not case:
raise PermissionDenied
document = get_object_or_404(Document, id=document_pk)

if any(user_type in [WONEN, WONINGCORPORATIE_MEDEWERKER] for user_type in request.user.user_type_values):
form_status_list = [f[0] for f in case.casestatus_set.all().order_by('form').distinct().values_list('form')]
shared_in_forms = [f for f in document.forms if f in form_status_list]
if not shared_in_forms:
raise PermissionDenied

if document.case != case:
raise PermissionDenied

if not default_storage.exists(default_storage.generate_filename(document.uploaded_file.name)):
raise Http404()

# Open the file and adjust the content type to match the file type
with default_storage.open(document.uploaded_file.name, 'rb') as file:
file_data = file.read()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deze code kan je nog lostrekken naar een aparte methode, is exact hetzelfde als in de download volgens mij

@remyvdwereld remyvdwereld merged commit 9f0855d into main Sep 18, 2024
3 checks passed
@remyvdwereld remyvdwereld deleted the feature/open-document-in-tab branch September 18, 2024 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants