summaryrefslogtreecommitdiffstats
path: root/packages/views
AgeCommit message (Collapse)AuthorFilesLines
2013-11-07Django 1.6 upgrade, deprecation cleanupDan McGee2-2/+2
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-17Various minor code cleanups and fixesDan McGee2-4/+1
Most of these were suggested by PyCharm, and include everything from little syntax issues and other bad smells to dead or bad code. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-17Add shortcut for HEAD requests on slower viewsDan McGee2-1/+6
We sometimes see some web bots and crawlers make HEAD requests to verify existence of certain pages in the application. However, they are less than kind as 20-50 requests might arrive at the same time, and package search and details pages are some of the slowest rendering pages we have due to the Django template engine. Rather than waste time generating the content only to throw it away, response as soon as we can with either a 404 or 200 response as appropriate, omitting the 'Content-Length' header completely, which seems to be acceptable by the HTTP spec. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-17Use require_safe decorator rather than require_GETDan McGee1-3/+3
This was added in Django 1.4, and ensures both GET and HEAD requests, but not POST requests, are allowed through. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-04-13Show replacments for package if it has been removedDan McGee1-0/+2
This covers the case where we can't find the package in any other repositories, but it was removed recently enough that we have a found package update object. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-27Use user.userprofile rather than user.get_profile()Dan McGee1-1/+1
The get_profile() function is deprecated as of Django 1.5. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-27Merge branch 'django-1.5'Dan McGee1-1/+1
Conflicts: requirements.txt requirements_prod.txt
2013-02-20Fix some fallout with moving page to query paramsDan McGee1-1/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-16Make page a query string parameter on package searchDan McGee1-0/+2
This is a bit silly to encode in the URL, or at least makes it much harder to screen out via robots.txt and other such things. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-16Remove configurable pagination for package searchDan McGee1-37/+1
Switch it to a hardcoded value of 100 for all searches instead. It didn't make much sense having a page number be part of the URL and a limit value being part of the query string. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-09Use 'update_fields' model.save() kwargDan McGee1-1/+1
This was added in Django 1.5 and allows saving only a subset of a model's fields. It makes sense in a few cases to utilize it. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-09Remove package seach by 'Last Updated After'Dan McGee1-9/+0
It is a lot easier to just sort the list rather than mess with this particular field, which didn't even allow you to specify a range or direction to search in. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-23Use more modern verison of string template formattingDan McGee1-6/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-23Use querysets for calls to get_object_or_404(Package)Dan McGee2-7/+7
This works better in most cases since we need the architecture and repository objects at some point during the view process. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-14Use content_type and not mimetype on HttpResponse()Dan McGee4-7/+7
Bug #16519 in Django deprecates mimetype, so update our code accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-12Make packages JSON search more performantDan McGee1-2/+6
We were peppering the database with a bunch of queries here; using prefetch_related and attach_maintainers can cut down the count significantly. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16Use python set comprehension syntax supported in 2.7Dan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16Use Python 2.7 dictionary comprehension syntaxDan McGee1-5/+3
Rather than the old idiom of dict((k, v) for <> in <>). Signed-off-by: Dan McGee <dan@archlinux.org>
2012-10-27Extract some common architecture grabbing logicDan McGee1-6/+9
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-30Fix usage of naïve datetime objectDan McGee1-2/+4
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-30Hide staging packages in search resultsDan McGee1-3/+12
This is for users that aren't logged in; developers will still see them. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-26Don't show staging in package search repo listingDan McGee1-1/+2
This is temporary or at least a quick way to ensure regular users aren't confused by staging packages; later updates should re-enable display of this for logged in developers and trusted users. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-15Remove now unnecessary importDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-08p/v/flag: Add reply-to to out-of-date notificationsFlorian Pritz1-3/+5
Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-21Use case-insensitive search in opensearch suggestionsDan McGee1-2/+8
There is no real good reason not to do this, since our packages are lowercased by convention. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-14Attempt to screen for useless out-of-date messagesDan McGee1-1/+11
Things like ' ', '-', '.', etc. will no longer be accepted in this field. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-09Migrate flag request version info to new formatDan McGee1-4/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01Revert "Fall back to 410 Gone for package files view as well"Dan McGee1-10/+2
This reverts commit 9ab460c53a1ac4c79da6f05f2850ee21beedbab2. This seemed like the right thing to do, but it doesn't really play well with our more general dispatch framework we now do on the package details pages. Just let it 404 like it always did, as these pages are less essential. We can perhaps add a full dispatcher later if we really feel the need.
2012-08-01Reuse removed template for packages with multiple replacementsDan McGee1-4/+20
For example, bitcoin-git in the Arch repos is currently marked replaced by both bitcoin-qt and bitcoin-daemon. This allows us to show a page with both options listed instead of a blank 404 page. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01Add package details redirect for package replacementsDan McGee1-1/+13
This makes sense if there is only one available replacement. We could get more sophisticated and show the removed page if there are multiple replacements available. Additionally, automatically redirect if there was only one matching package for a given package update deletion object. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01Rework package details dispatch codeDan McGee1-37/+45
We had a variety of fallback paths that we took if a details page didn't exist for the combination of URL parts passed in. Before I go adding a few more possibilities, rework this so it is more flexible. It is now as simple as adding a method to the dispatch options list in order to have further fallback options. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-31Fix broken hidden input sort field on search formDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-25Replace deprecated list_detail usage in search with class-based viewDan McGee2-39/+40
We can convert the entire search view to a generic class-based ListView. This is still one of the more disgusting views in the application and has a ton of logic scattered buckshot across several methods, but this commit is not meant to address all of that in one go. This is the last of the deprecated pieces I know of we are still using in the codebase, so we should be relatively safe in the long run now for an upgrade to the eventual next major Django release. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-25Replace deprecated direct_to_template() with render() shortcutDan McGee4-24/+17
Now that Django actually provides a concise way to use a RequestContext object without instantiating it, we can use that rather than the old function-based generic view that worked well to do the same. Additionally, these function-based generic views will be gone in Django 1.5, so might as well make the move now. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-25Remove custom utc_now() function, use django.utils.timezone.now()Dan McGee2-6/+6
This was around from the time when we handled timezones sanely and Django did not; now that we are on 1.4 we no longer need our own code to handle this. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-24Fall back to 410 Gone for package files view as wellDan McGee1-2/+10
This is another thing that Google and other search engines try to crawl that no longer exists at times, so we should handle it gracefully. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-24Ensure package files JS can support corner casesDan McGee1-0/+6
We should handle the cases dealing with no filelist available, outdated filelist, or a package without files, just as the HTML server-side page does. Add a bit more info to the JSON returned so we can do so. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-24Remove files list AJAX conditionalsDan McGee1-4/+0
Now that we just generate this list in JS, we don't need this separate code. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-23Add '410 Gone' support for packages moved out of repositoriesDan McGee1-5/+41
This allows us to do better than a generic 404 handler when we know a package previously existed in a given repository, and should also make things a bit nicer when getting sent in from a search engine to a page that no longer exists. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-21Split details/display package views into new moduleDan McGee2-147/+167
This moves a lot of the package and group display logic into a new view module, similar to what we already did earlier with a bunch of other views. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-19Issue redirects from non-agnostic to agnostic URLs if unambiguousDan McGee1-0/+10
For something like "/extra/i686/apache-ant/", we can redirect to "/extra/any/apache-ant/" without ambiguity. Previously this redirected to the split packages listing with a single package, which was neither correct nor really expected. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-12Use python json module directly in place of simplejsonDan McGee3-13/+9
As of Python 2.6, this is a builtin module that has all the same functions and capabilities of the Django simplejson module. Additionally simplejson is deprecated in the upcoming Django 1.5 release. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-05Fix suggestion caching again for non-ASCII charactersDan McGee1-1/+2
This is why you should test this stuff with random input before rolling it out. Whoops. URL that caught this problem: /opensearch/packages/suggest?q=%D7%A0%D7%9F%D7%92%D7%9F aka /opensearch/packages/suggest?q=נןגן Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-04Fix search suggestions for invalid cache keysDan McGee1-2/+3
Unfortunately, "invalid" in this case includes spaces, which is a bit crazy. MD5 the provided search term before using it as a cache key to be safe. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-02Flagging related cleanups and improvementsDan McGee1-10/+24
Touch up the style slightly on the flag help popup to match the main site style more closely. When a logged-in user is flagging a package out of date, we have no need for them to fill in the email field since we already have an email address on file. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-02Add some caching to the Opensearch-related viewsDan McGee1-5/+13
Both some simple cache headers as well as low-level results caching on search terms suggestions. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-02Opensearch enhancementsDan McGee1-1/+17
* Add a 64x64 icon as indicated in the Opensearch specification. * Add suggestions capability and a new view providing suggestions based on package name starting with the typed value. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07Add JSON search viewDan McGee2-1/+27
This still might change and should not be viewed as a public API yet. This has been a longstanding request in FS#13026. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07Move PackageJSONEncoder into package.utils moduleDan McGee1-36/+3
This will allow it to be used elsewhere, and doesn't really belong in views anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-07Choose an up-to-date mirror for download URLsDan McGee1-9/+4
Given that we collect a lot of mirror status data, we can utilize it to ensure the download link on the website actually works and newly-added packages have actually been mirrored out. Add a method that attempts to use the mirror status data to determine a mirror we should redirect our download requests to. This can change on a regular basis, and falls back to the old method if no mirror status data is available. Signed-off-by: Dan McGee <dan@archlinux.org>