-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Audit log: log invitations #9607
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
Conversation
a2f42a8
to
5e8bc7d
Compare
5e8bc7d
to
dcffedb
Compare
readthedocs/audit/models.py
Outdated
PAGEVIEW = Actions.PAGEVIEW | ||
DOWNLOAD = Actions.DOWNLOAD | ||
AUTHN = Actions.AUTHN | ||
AUTHN_FAILURE = Actions.AUTHN_FAILURE | ||
LOGOUT = Actions.LOGOUT | ||
INVITATION_SENT = Actions.INVITATION_SENT | ||
INVITATION_REVOKED = Actions.INVITATION_REVOKED | ||
INVITATION_ACCEPTED = Actions.INVITATION_ACCEPTED | ||
INVITATION_DECLINED = Actions.INVITATION_DECLINED |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set these here to avoid having to refactor every place where we use them, and it's also easier to write AuditLog.PAGEVIEW
than AuditLog.Actions.PAGEVIEW
. We could also move this outside the model, so we can just write Actions.PAGEVIEW
, but that will require changing every usage too, so.
|
||
<span class="quiet right" title="{{ log.created|date:"DATETIME_FORMAT" }}"> | ||
{% blocktrans trimmed with log.created|timesince as date %} | ||
{{ date }} ago | ||
{% endblocktrans %} | ||
</span> | ||
|
||
{# Data about the log entry #} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches what I was describing the other day. The main translated string is "Country changed from your previous session", without introducing variables, and metadata is listed below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't do a thorough job looking at Python, so would be good to get secondary review there. I'll have a lot of updates for this view when we get to reworking this UI, but for now, my inclination is probably to keep this UI very simple, and add more complex UI with new templates.
Addressing what we're storing and displaying is a great focus for this stage. We can come back to this UI with more complex additions, like filtering and search.
|
||
<span class="quiet right" title="{{ log.created|date:"DATETIME_FORMAT" }}"> | ||
{% blocktrans trimmed with log.created|timesince as date %} | ||
{{ date }} ago | ||
{% endblocktrans %} | ||
</span> | ||
|
||
{# Data about the log entry #} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches what I was describing the other day. The main translated string is "Country changed from your previous session", without introducing variables, and metadata is listed below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR is fine. However, I'd invite another person to do a code review as well. To me, there are some new magic added in this PR that we have not been using and it's changing some of the patterns we have for the same things. I usually prefer consistency in these cases.
These new decisions made me spent more time than I would normally require to review this code. Changes aren't huge or complex, but I had to re-read multiple times them to understand the new approaches used for the same things we have solved in a different --and no that magic-- way.
AuditLog.objects.new( | ||
action=action, | ||
request=request, | ||
data=InvitationSerializer(self).data, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This called my attention. I was wondering why we had created the readthedocs/invitations/serializers.py
file if we are not exposing invitations via a REST API.
It seems we are using the DRF serializers for a different purpose here and I'm not convinced this is the right approach.
@stsewd We're doing some sprint clean up, is there anything required on this PR to move forward? |
@agjohnson there is a disagreement about using django's enum types for constants/options #9607 (comment). |
|
||
to_user = UserSerializer() | ||
from_user = UserSerializer() | ||
object = serializers.SerializerMethodField() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isnt' it a problem to override the object
reserved word?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only when used as variable name, we can change it to obj
if we want
readthedocs/audit/serializers.py
Outdated
def get_object(self, obj): | ||
serializers = { | ||
"organization": OrganizationSerializer, | ||
"project": ProjectSerializer, | ||
"team": TeamSerializer, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have a comment here saying that the value of object
will depend on the object type and a different serializer will be used.
Had to do some refactoring now that we are introducing more actions to logs, there are:
(useful to store information about the invitation)
Screenshots
Closes #9456.
📚 Documentation previews 📚
docs
): https://docs--9607.org.readthedocs.build/en/9607/dev
): https://dev--9607.org.readthedocs.build/en/9607/