Skip to content

Improvements to Admin pages for the API Section#289

Merged
jb3 merged 35 commits into
masterfrom
admin-api-pages-improvements
Sep 20, 2020
Merged

Improvements to Admin pages for the API Section#289
jb3 merged 35 commits into
masterfrom
admin-api-pages-improvements

Conversation

@scragly
Copy link
Copy Markdown
Contributor

@scragly scragly commented Oct 19, 2019

I've added some QOL adjustments to the admin pages by defining ModelAdmin objects for most all of the API section's models:

Bot Settings

See details

Permissions

image

View Add Delete Change

List View

Columns shown: name
Filter by: None

image

Item View

Fields: name, data (editable)

image

Documentation links

See details

Permissions

image

View Add Delete Change

List View

Columns shown: package, base url (editable), inventory url (editable)
Ordered by: package (alphabetical)
Searchable by: package
Filter by: None

image

Item View

Fields: package, base url, inventory url

image

Infractions

See details

Permissions

image

View Add Delete Change
reason

List View

Columns shown: type, active, user, inserted, reason
Ordered by: inserted descending
Searchable by: id, user name, user id, actor name, actor id, reason, type
Filter by: type, hidden, active, actor

image

Item View

Fields: user, actor, type, hidden, active, inserted, expires, reason (editable)

image

Log entries

See details

Permissions

image

View Add Delete Change

List View

Columns shown: timestamp, level, message
Searchable by: message
Filter by: log level, timestamp

Note: "application" has been removed from filter and columns as we no longer use this api for external logs.

image

Item View

No changes.

image

Deleted messages

See details

Permissions

image

View Add Delete Change

List View

Columns shown: message id, author, channel id
Ordered by: id descending
Searchable by: message id, content, author name, author id, actor name, actor id
Filter by: None

image

Item View

Fields: id, author, channel id, content, embeds (pretty json formatting), context link, view log (link to staff.pydis log view)

image

Message deletion contexts

See details

Permissions

image

View Add Delete Change

List View

Columns shown: id, creation, actor
Ordered by: most recent

image

Item View

Fields: actor, creation, child messages (as inline tabular view)

image

Nominations

See details

Permissions

image

View Add Delete Change
reason
end reason

List View

Columns shown: username (with discrim.), active, reason, actor name (with discrim)
Ordered by: most recent
Searchable by: user name, user id, actor name, actor id, reason, end reason
Filter by: active, actor

image

Item View

Fields: user, active, actor, reason (editable), created, ended, end reason (editable)

image

Off topic channel names

See details

Permissions

See details

image

View Add Delete Change

List View

Columns shown: name
Searchable by: name
Filter by: used

image

Item View

Fields: name, used

image

Offensive messages

See details

Permissions

image

View Add Delete Change
delete date

List View

Columns shown: message id, channel id, delete date
Searchable by: message id, channel id
Filter by: None

image

Item View

Fields: message id (value hyperlinked to discord jumplink), channel id, delete date (editable)

image

Roles

See details

Permissions

image

View Add Delete Change

List View

Columns shown: name (coloured)
Ordered by: position
Searchable by: name, id
Filter by: None

image

Item View

Fields:

  • id
  • name
  • colour
    • coloured text
    • shown as both hex & int values
  • permissions
    • value links to the Discord API Permissions Calc page to show all the permissions (example)
  • position

image

API User

See details

Permissions

image

View Add Delete Change

List View

Columns shown: username (incl. discrim), top role (coloured), in guild
Ordered by: username (incl. discrim)
Searchable by: name, id, role id
Filter by: role membership, in guild

image

Item View

Fields: username (incl. discrim), id, in_guild, role vertical list (coloured)

image

Copy link
Copy Markdown
Contributor

@SebastiaanZ SebastiaanZ left a comment

Choose a reason for hiding this comment

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

Is there a way to make certain fields optional in the Admin back-end? If you, say, edit a note infraction, you won't be able to save your changes unless you set an expiry date.

2019-10-25_17-15

I think that would be an improvement as well.

@fiskenslakt
Copy link
Copy Markdown
Contributor

fiskenslakt commented Oct 27, 2019

I'm in the middle of thoroughly testing this branch as I populate my local database, and I've run into an odd bug. Please tell me if you can reproduce it.

Steps to reproduce:

  1. Go to /admin/api/tag/f-strings/change/ on production site and copy the JSON content inside the embed field.
  2. Go to /admin/api/tag/ on your local development site and create a new tag with the ADD TAG + button
  3. Enter a title for the tag
  4. Paste in the copied JSON into the embed field
  5. Click the Save and continue editing button

Expected behavior:

  1. Tag is saved
  2. Edit tag screen is displayed and tag markdown is rendered

What I got instead:

  1. Tag is saved
  2. Django raises a KeyError: snake

@jb3 jb3 requested review from a team, MrHemlock and jerbob and removed request for a team February 2, 2020 20:20
@lemonsaurus lemonsaurus added area: API Related to or causes API changes priority: 2 - normal Normal Priority status: waiting for author type: feature New feature or request labels Feb 29, 2020
@lemonsaurus
Copy link
Copy Markdown
Contributor

@scragly any idea when you'll be able to address the reviews here?

@scragly
Copy link
Copy Markdown
Contributor Author

scragly commented Mar 10, 2020

Tonight maybe. I only just got the local copy going again today.

@lemonsaurus
Copy link
Copy Markdown
Contributor

excellent. thanks for the quick reply.

@lemonsaurus
Copy link
Copy Markdown
Contributor

@scragly This pull request is very stale. It looks like it's like 98% done, so it'd be a shame to have to close it. I really wish you'd find some time to finish it, but otherwise I'm considering whether we should just merge it even with the reviews unaddressed. I mean, having this feature with a few bugs is probably better than never having it.

@scragly
Copy link
Copy Markdown
Contributor Author

scragly commented Aug 26, 2020

I should have a bit of time today to address the reviews and to bring the changes up to date with master. I'll try jump on after breakfast too get it sorted.

# Conflicts:
#	pydis_site/apps/api/admin.py
@scragly
Copy link
Copy Markdown
Contributor Author

scragly commented Sep 18, 2020

If you, say, edit a note infraction, you won't be able to save your changes unless you set an expiry date.

The issue for non-expiring infractions being unable to save changes has been addressed coincidentally, but out of concern that the bot infraction tasks will desync if editing expiry is allowed external to the bot.

I've double checked, and turning the expiry read-only results in successful reason edits.

@scragly
Copy link
Copy Markdown
Contributor Author

scragly commented Sep 18, 2020

I'm in the middle of thoroughly testing this branch as I populate my local database, and I've run into an odd bug.

Through the power of laziness, neglect and sheer forgetfulness, much time has passed, and just as the water stream eventually erodes the rock, we have lost the presence of tags in the database, with them being stored back in repos. Hence, time is the true solution to all that is bad with the world.

@scragly scragly requested a review from a team as a code owner September 18, 2020 05:58
@scragly scragly requested a review from ikuyarihS September 18, 2020 05:59
@scragly
Copy link
Copy Markdown
Contributor Author

scragly commented Sep 18, 2020

I've gone through and tweaked edit permissions for certain models, and atm it's showing the following in the admin site:
image

Figured I'd give a bit of an update. I'll try get a proper update coming tomorrow, but unfortunately I'm absolutely wrecked and need sleep.

`avatar_hash` is no longer a field stored in the database.
Filter checks for general role membership instead of only those who have the selected role as top role. Noticed during development that we'd not be able to filter to show all Helpers otherwise, as some Helpers have different top roles such as Core Dev that wouldn't give immediately obvious behaviour to user expectations.
@scragly scragly force-pushed the admin-api-pages-improvements branch from a3fe02a to dafca0f Compare September 19, 2020 16:06
Without `blank=True`, admin page editable forms could not be saved if no content was in the end_reason input.
I'm unable to see any cases where this would be wanted, and instead accidental deletion would result in the system possibly breaking, as we are unable to add the setting again to replace it if it got removed.

The name has also set to read only in item view, to prevent renames, effectively doing the same thing as deleting it.
@scragly scragly force-pushed the admin-api-pages-improvements branch from 3fc5aa7 to a105de7 Compare September 19, 2020 21:06
Copy link
Copy Markdown
Contributor

@lemonsaurus lemonsaurus left a comment

Choose a reason for hiding this comment

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

An exceptionally good PR. Beautifully described, well documented code, concise, and useful.

Copy link
Copy Markdown
Member

@jb3 jb3 left a comment

Choose a reason for hiding this comment

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

Excellent PR

@ghost ghost removed the needs 1 approval label Sep 20, 2020
@jb3 jb3 merged commit 5e8b551 into master Sep 20, 2020
@jb3 jb3 deleted the admin-api-pages-improvements branch September 20, 2020 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: API Related to or causes API changes priority: 2 - normal Normal Priority type: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants