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

Initial DSC & Django update #660

Merged
merged 30 commits into from
May 6, 2024
Merged

Initial DSC & Django update #660

merged 30 commits into from
May 6, 2024

Conversation

tymees
Copy link
Member

@tymees tymees commented Apr 22, 2024

This PR lays the foundations to built V4 upon.

Note: this PR targets the major/4 branch for now. This is a fork of develop made at the same time as the source branch, to have a clear diff. New changes in develop will need to be merged into there as well.

It's a rather large PR; I've tried to make proper commits for individual changes, to help reviewing. I've also added some comments over adding them here, such that the comment is located near the relevant code.
Also, please ignore the changes in the docs folder. Those are caused by my bulk-refactors.

Highlights:

  • Update to Django 4.2
    • I think I got this all sorted, but there might still be some problems lurking in the later form pages
  • Updated to DSC 3
    • New app-specific base template (and moved all pages to it)
    • New form-specific base template (and moved the first form + WMO forms to it)
    • New home-page design. (Needs sign-off from desiree)
    • Initial automatic CSS migration pass (renaming classes to their new equivalents mostly)
    • Ported form-JS utils to new form (non-table-based) layout

Still todo:
Well, a lot. A non-exhaustive list:

  • Layout polishing pass
  • All other form pages need to be converted to the new form-base-template
    • In addition, some pages might need to be split up to be less intimidating
  • All other pages need to be (re-)reviewed.
  • A proper stepper implementation
  • New overview pages using UU-List. (Ideally we'd cut down on the amount of those pages in favour of filters)
  • Everything else in https://github.com/DH-IT-Portal-Development/ethics/milestone/3
  • And probably stuff I'm forgetting

@tymees tymees marked this pull request as draft April 22, 2024 12:52
Copy link
Member Author

Choose a reason for hiding this comment

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

I've moved the original contents to style.css.bak. I did this because I want us to manually review anything we need from there. A lot of it is unneeded now, and other stuff might be better implemented using existing classes from BS.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the new base template for ethics, to be used by all pages either directly or indirectly. It mostly implements the header styling, leaving the main content styling up to the DSC provided template.

Note: the current header isn't quite finished, it still needs a polishing pass. However, that would delay this PR, and it's functional enough for now

Copy link
Member Author

@tymees tymees Apr 22, 2024

Choose a reason for hiding this comment

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

This is the more controversial one of the two new base templates. This template is designed to be used by most 'form'-templates (with 'form templates' I only mean the ones part of the actual application. We have other forms in the app, like 'copy', that should just the normal base template. (Altough, we could create a more generic form-template that handles for FormView-derivatives, that handles the HTML for forms.)

Note: some of our application-form-pages are a bit special, and might need a custom template instead of this 'automagic' template.

This template sets a pre-set layout, providing specific blocks to override to put content in said content. See the following image for a visual overview of the available blocks and where they are:
image

Notes:

  • The sizes of the blocks were hardcoded by me, they scale dynamically to the content (vertically)
  • All blocks can be left empty. In the pages I've conferted I've used pre-form to add the page-title
  • The stepper is a block, but ideally that block would never need to be overwritten by any implementing page.
  • The're a block form-css-classes not visually present in the image above. This is a block one can use to add extra css-classes to the uu-form element. (For example uu-form-no-gap, or uu-form-no-help).

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome work, and great image.

I think the pre-form, form-buttons, and post-form should be easily splittable into a their main content and an aside, as with the actual form.

This makes a more sense stylistically, for example to align the buttons to the main form body. This also allows for an aside to the pre-form intro text, for example with some "handige links" like we do in procreg.

Of course this is already possible if you code it yourself or reuse the classes. However, it would be nice to have it supported by default everywhere in the form by having separate pre-form-content and pre-form-aside blocks you could use right away.

And then a parent pre-form block which gives you the full width if you replace it.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a great suggestion! As it's quite easy to implement, I've done so:
image
Some notes:

  • As you suggested, these new blocks are childs of the existing pre/post-form blocks, so you can still override those as before.
  • I called pre-form-content pre-form-text instead, as that mirrors the class .uu-form provides for this usecase
  • I didn't split up form-buttons into an aside, as I don't see a usecase where that makes sense to actually use. I did change the HTML to use the same text classes as the new blocks, such that the buttons are aligned with the form as you suggested.
  • With this buttons-change, we probably want make those form buttons smaller. Currently I think it's a bit claustrophobic

Copy link
Member Author

Choose a reason for hiding this comment

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

Controversially, I removed all buttons aside from next/prev. Mostly because the new stepper should be the new best-way to nagivate to things.

Copy link
Member Author

Choose a reason for hiding this comment

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

This was the old stepper. It's still referenced on a lot of pages, so I just made an empty file for now

Copy link
Member Author

Choose a reason for hiding this comment

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

This is a exceptionally terrible implementation of the new stepper on top of the old stepper code; it's mostly for show.

In a different issue, this should be replaced with a properly working one (ideally with status indication, and better hierarchy).

@@ -57,8 +57,58 @@ def get_queryset(self):
return self.model.objects.filter(not_after__gt=now, not_before__lt=now)


class HomeView(LoginRequiredMixin, _SystemMessageView):
class SeasonalCoverImageMixin:
Copy link
Member Author

Choose a reason for hiding this comment

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

Okay so this addition is 100% unnecessary. I just wanted to have a bit of fun during a boring meeting.

It adds a seasonal-appropiate cover-image automatically.

The winter and autumn covers are the ones we already had, the spring and summer ones are new.

Note 1: I made the old 'summer' version the 'autumn' one. Mostly because it had people in winter-coats in it, so it wasn't really summer.
Note 2: I found out that our attributions we had before were wrong! We listed the person who added the image to the image-bank, not the actual photographer themselves. The ones listed here now are correct.

Comment on lines +629 to +631
def form_valid(self, form):
messages.success(self.request, self.success_message)
return super(DeleteView, self).delete(request, *args, **kwargs)
return super(DeleteView, self).form_valid(form)
Copy link
Member Author

Choose a reason for hiding this comment

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

Django 4 changed how deleteviews worked. For those wondering where this and other similar changes comes from.

@tymees tymees marked this pull request as ready for review April 23, 2024 11:38
@tymees tymees requested review from miggol and EdoStorm96 April 23, 2024 11:39
Okay, this should be all of them now. RIGHT?!
Copy link
Contributor

@EdoStorm96 EdoStorm96 left a comment

Choose a reason for hiding this comment

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

Wow, very good work :) I mainly looked at what you changed, not so much at what stayed the same. And i did some, but non-exhaustive testing. It all looks good and consistent. The one thing I think you overlooked is to remove {% load uil_filters %} from a few templates. This caused an error for me at one point in testing.

I also quite like the philosophy of the new fetc_form_base template. I think the places you've used the new boxes, show the potential of this nicely.

All in all, I'm happy and excited to continue working on this!

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a btn class to the submit button on this page. My bad, i think :p

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, this is one of the files only touched by my automatic refactoring runs; and I didn't do a check for naked submit buttons. (There are probably more?)

And not really your fault; the previous CSS handled that automatically for you, the new one doesn't.

@tymees
Copy link
Member Author

tymees commented Apr 25, 2024

Thanks for the review!

I've added a commit that refactors all uses of uil_filters.

There are probably more of these 'well you could've done that in bulk' problems still living in other places; I've only done those I was aware of, and those I found during my work on the pages I gave individual attention.

Normally we go with the 'one approval is enough' strategy, but I really want @miggol's review before merging, as it's quite an impactfull PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Landing

image

  • The middle-aligned navigation bar up top looks weird. Like it's crying for help. I think aligning it to the right/flex-end would help. I expect this would look find for most other pages with more nav items.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah honestly I think the menu should just be empty if you're not logged in, especially if we add the footer from index.html here as well.

It's middle-aligned because procreg is middle-aligned, and it's a bit annoying to fix that manually for this one case

Copy link
Contributor

Choose a reason for hiding this comment

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

  • I would like to add the footer from index.html to this page. The documents links might not be as relevant, but all the support addresses are.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good idea!

However, it's (sadly) not as simple as moving some HTML around. landing.html has some extra JS to protect against spambots scanning mailto: links, which we'd have to re-introduce. I'd rather create a separate issue for this, to implement that correctly.

Copy link
Contributor

Choose a reason for hiding this comment

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

Awesome work, and great image.

I think the pre-form, form-buttons, and post-form should be easily splittable into a their main content and an aside, as with the actual form.

This makes a more sense stylistically, for example to align the buttons to the main form body. This also allows for an aside to the pre-form intro text, for example with some "handige links" like we do in procreg.

Of course this is already possible if you code it yourself or reuse the classes. However, it would be nice to have it supported by default everywhere in the form by having separate pre-form-content and pre-form-aside blocks you could use right away.

And then a parent pre-form block which gives you the full width if you replace it.

Copy link
Contributor

@miggol miggol left a comment

Choose a reason for hiding this comment

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

Alright, I've been browsing for a while and overall I'm very impressed. Most things are simply working.

There's some stuff still missing but I'm sure we'll get to it soon enough in the django-4 branch.

@tymees tymees merged commit 839a349 into major/4 May 6, 2024
3 checks passed
@tymees tymees deleted the update/django_dsc branch May 6, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants