-
Notifications
You must be signed in to change notification settings - Fork 6
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
Big Source Changes, Much Improvements, Wow. #1545
Conversation
adds blocks for title and scripts so that templates can put those parts in the header.
The title and scripts are no longer simply added to the body of the page, but are now actually contained by the header, where they should be.
Since the siglum and institution name now come from the institution, the source only needs to have the shelfmark. However, until all the data is properly migrated, the old title and siglum fields will remain.
This is a hacky, change-as-needed script that serves to migrate the source data from the old structure to the new, creating institutions and moving the shelfmark data to the new sources. There is a whole bunch of sigla that get skipped (essentially all private collectors) until we figure out how they will be handled. Don't look to closely, since there are lots of skeletons in this closet.
Allows sources to be added to an institution by using the autocomplete widget
Previously, the LoginView import in the URLs was taken from the views.user module, instead of directly from the django auth views, because this view was also imported into the user module. (aka, a transitive import). This changes it to import from the auth views directly. I also ran a formatter on the imports in the user module, so that's why it looks like there are more changes than there actually are!
Previously there were several duplicated property definitions that varied only by checking whether the user was logged in. They also did the sorting in Python, rather than in the database. This condenses all the definitions to a single one per property, and uses the expanding empty dict trick to determine whether `published=True` gets added to the filters. (Since without this, what is really desired is `published = True OR False` but without resorting to Q queries this was the simplest way to do it.)
This commit completely reworks the fetching of data for the feast detail page. Previously, this page took several seconds to load, and generated a large number of queries, due to the complexity of the information needing to be collated. This was rewritten to instead use two custom SQL queries that are executed directly. This means that the number of queries generated by this segment of code is now no more than two. There are a few 'interesting' things in this, which I've tried to note in comments. In the process, this also fixes a number of other small bugs: Fixes #1540 Fixes #1136 Fixes #596
This commit reworks the source display in the templates, primarily by calling a couple helper methods on the Source model to keep the referencing consistent. The 'short heading' method displays the Institution siglum and the shelfmark, while the 'heading' displays the full institution name and the shelfmark. The edit and create templates were reworked for the new structure and source referencing. The source display will now show the institution and the shelfmark in separate columns.
This is to allow saving sources in the create / edit without triggering a validation error.
oo, shiny!
|
further screenshot commentary: |
Good catch! I've fixed it.
I'm working from a slightly older DB export at the moment, so it may not be completely up-to-date. P-Pm has the title "Porto 1511", which didn't match the "city, institution, shelfmark" pattern, so it got skipped in the conversion. It shows up as None None because of this.
It's only optional during the transition, since we can't automatically move everything and leave nothing blank. Once we've migrated everything and it "goes live" the option to leave it blank will be removed.
That's kinda up to you guys. Do you want to allow people to add their own institutions, or would you rather create them on request. (I suspect the latter.) The only weird bit is Private Collectors, but I'm still working on a proposal for that. Thanks for the review! |
Buckle up, this one's a bit messy. This commit disables the Feast Detail tests. It turns out, after much searching and Googling and digging, that the Django Test Suite always wraps the tests in a transaction, so that the test can be easily rolled back after each one is run, and thus present a database in a known state for each individual test. However, with the switch to running a raw SQL query, the cursor in the Feast Detail View now runs outside of this transaction. Thus to the View, the database always looks empty, even if it's running inside of the test. I tried fixtures, TransactionTestCase, overriding methods and hacking the TestCase to prevent this behaviour, but no dice. So for now I've marked the Feast Detail tests as "skip" so that they still appear in the runs, but are skipped because they will always fail, as they're written.
It's better to use the named fields for the column content than to rely on the order of the tuple unpacking....
Still failing, but being worked on. Committing here to merge in latest changes.
# Conflicts: # django/cantusdb_project/main_app/templates/browse_chants.html # django/cantusdb_project/main_app/templates/chant_create.html # django/cantusdb_project/main_app/templates/chant_detail.html # django/cantusdb_project/main_app/templates/chant_edit.html # django/cantusdb_project/main_app/templates/melody_search.html # django/cantusdb_project/main_app/templates/source_detail.html # django/cantusdb_project/main_app/templates/source_edit.html # django/cantusdb_project/main_app/templates/user_source_list.html
Syncing the templates with the latest develop generated a number of merge conflicts. This commit fixes them. Also it fixes the new block definitions in the base templates. Fixes #1551
The provenance and century detail pages have odd orderings now when changes to templates and views are combined. I'll make a new issue to match what we now do with notation views. |
The preferred ordering was unclear to me. In many places it was done by siglum, so the Austrian ( This is fine, but the format for the full heading doesn't actually contain the siglum, only the full institution name and the shelfmark. I could imagine something like Then the sorting of the list would make sense, even though the siglum isn't the first component of the title. If that is what is wanted, then "(I-CF) Cividale del Friuli, Archivio Capitolare" is probably best. |
To me too, which is why I think it makes sense to separate. As it is now, it can just look totally random which probably doesn't make sense. The second option you list (eg. |
i believe this was discussed a bit here? #1227 |
@ahankinson One last question, I think: In the description above you write that there is still work to be done to figure out "private collections" and that this will lead to some sources showing up as I'm getting institutions that look like this: I'm also getting other weird institutions. For example, here's the US library of Congress: I assume that this latter has to do with the way the names of sources were in the original data. If the intention is that we'll have to do this manual clean-up, all fine, I just want to make sure that's expected. |
Yes, now that I look at it, the source list page suffers from this too now (ordering by something that isn't visible). I guess whatever we choose for the source list page should probably carry over to the other pages that list sources too. Title will no longer be an option so we'll have to update what we want in #1227. |
A “title” doesn’t really make sense when talking about MSS… at least it’s not a universally recognized concept. The identifiers we can sort on are:
Personally I find sorting by country code, then city, and then institution name to be the most useful, since it groups all the mss from the same institution, and groups all institutions in one city. As long as it’s understood how they’re sorted then that’s probably the best way. |
Thanks @ahankinson for all of this!! From my pov, we should merge this if you are good and this makes sense #1545 (comment) |
Interesting...I thought I did but let me try again. |
The same thing happened to me again... @lucasmarchd01 have you tried? Update 1: I didn't realize that @ahankinson had done significant updates to the data on production to accompany this PR. Local and staging databases need to be updated with a recent production dump for this to work. Update 2: |
I don't see any of those institutions in my data... |
Looks like all are recent (past month) additions. I'm gonna merge, we'll fix them in the data later. |
I did a fresh export from the cantus database today (the export is currently in /home/fedora on the server) and dropped / re-created the database on my local machine. So I'm not sure how they got there...
Anything wrong with that? |
I think they are all part of a dump of private collection fragments I'm working on that's still very much in draft form! So that's me. |
But... if they're not in the database dump I literally took from the production server today, where did they come from? Or am I getting the dump from the right place? Edit: OK, I see them on production. They will need to be fixed post-migration. |
Looks like we have this figured out, but for reference, a new database dump is created every day in |
OK! |
This commit adjusts the columns in the browse sources table to conform to the changes in source identification introduced in DDMAL#1545. Refs: DDMAL#1569
This PR contains a whole boatload of improvements. In talking with @dchiller about this we thought we would do a monolithic PR to start with, and then see if anything needed to be changed before merging.
At its core this PR changes the way Source records are captured. With the introduction of the Institution model, the siglum and the institution name are now found in that table, and the Source identifier (the shelfmark) is replacing the former title and siglum fields on the Source model.
Along the way, a number of other changes were made.
<title>
and<script>
tags were moved to their appropriate blocksThe biggest change, however, is the rework of the Feast detail page. The previous code was very slow to load the page, but this is now pretty fast through the use of two raw SQL queries to fetch the necessary data for the view. I've compared it with the numbers from the existing setup, and it seems to give the same results, but the page load time has gone from 3+ seconds to ~250ms, and 1,500 queries (in one case) to a pretty constant 8 (in total for the page load). It also fixed a few problems with this page, and displays all the genres associated with a given chant, instead of just one.
How to review this PR
Normally I don't like large PRs, but it seemed appropriate that, since I was touching so many places to rework sources that I could also improve these places as I went.
I've tried to explain the changes thoroughly in every commit message. I'm also posting a few screenshots to compare the old and new changes.
Outstanding issues
Still to-do is to figure out how to deal with Private Collections. You may notice this in some places where a source will have
None
-- this just means there is a source, but it hasn't been migrated to the Institution / Shelfmark model, so it's not displaying the right data. This should be fixed before this PR is merged.Also not tackled is any search interface, specifically how it deals with looking up sources by "siglum." Still TBD, particularly if we want to not break any existing searches... Feedback is useful here.
Screenshots
Changes on the left, Current Production on the right.
Feast detail. Note the genre column, and the removal of the chant with no cantus ID.
Browse Source chants, with removed siglum column
Edit Source, with Holding institution and shelfmark