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

Add toasts and login form #7

Merged
merged 12 commits into from
Jul 24, 2024
Merged

Conversation

bartacc
Copy link
Collaborator

@bartacc bartacc commented Jul 7, 2024

This PR contains:

  • Added toasts which are displayed automatically whenever django calls messages.<message_level>()
  • Added /login form with some code that automatically generates frontend code from Django's forms
  • Added a <CenteredContainer/> component, which caps width of elements based on screen size. I also refactored many other components to use it, so that the entire website behaves consistently with different screen sizes.
  • Refactored User context processor to use a nested user object (which is accessed in React with context.user.some_property, rather than context.some_property). Custom context processors are not well documented in Reactivated, so I initially missed the fact that it can be achieved this way.

app/client/components/Alert.tsx Outdated Show resolved Hide resolved
app/client/components/Layout.tsx Show resolved Hide resolved
app/client/components/forms/BasicFormField.tsx Outdated Show resolved Hide resolved
app/client/components/forms/BasicForm.tsx Outdated Show resolved Hide resolved
app/client/components/forms/BasicForm.tsx Outdated Show resolved Hide resolved
"user": {
"is_authenticated": request.user.is_authenticated,
"is_staff": request.user.is_staff,
"email": request.user.email if not request.user.is_anonymous else "",
Copy link
Member

Choose a reason for hiding this comment

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

I think request.user.is_anonymous or "" will suffice.

Applies to request.user.first_name and request.user.last_name` as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't really understand.

If you mean "email": request.user.is_anonymous or "", then it doesn't make sense, because we need to provide the request.user.email value

If you mean "email": request.user.email or "", then it also won't work, because if user is anonymous the user.email field doesn't exist (since then user is of type AnonymousUser, not User), so we get an exception.

Copy link
Member

@ref-humbold ref-humbold left a comment

Choose a reason for hiding this comment

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

Good job!

@bartacc bartacc mentioned this pull request Jul 24, 2024
@bartacc bartacc merged commit 91e5596 into develop Jul 24, 2024
1 check passed
@bartacc bartacc deleted the bartacc/basic_pages_implementation_2 branch July 24, 2024 21:21
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