Commit Graph

83 Commits

Author SHA1 Message Date
Jelle van der Waa
273c27adea Change signoff permissions for Testers group
Change the permissions required for a signoff, so that the testers group
does not need change_package permission

Signed-off-by: Jelle van der Waa <jelle@vdwaa.nl>
2017-06-05 22:10:51 +02:00
Dan McGee
becb5b2356 Fix error in test where HTTP_HOST doesn't exist
Signed-off-by: Dan McGee <dan@archlinux.org>
2015-04-15 17:23:18 -05:00
Dan McGee
94d1c96ac9 Ensure packager=unknown query works as expected
I broke this in commit dca00e7aab, whoops!

Signed-off-by: Dan McGee <dan@archlinux.org>
2015-01-29 20:16:37 -06:00
Dan McGee
dca00e7aab Filter maintainer list on packages page by allowed repos
We do this elsewhere on the master keys page, so do the same thing here.

Noticed-by: Johannes Löthberg <johannes@kyriasis.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2014-12-02 14:57:03 -06:00
Dan McGee
7c46d07f64 Use varied prime numbers for caching lengths
Signed-off-by: Dan McGee <dan@archlinux.org>
2014-10-19 18:12:58 -05:00
Dan McGee
061805aa73 FS#30773: put exact matches at top
There have been a few proposed solutions to this, but there really isn't
anything without a drawback. Things break pagination, require loading
the entire result set from the database, etc.

Just plop a new table on the page if someone did a so-called "simple"
search and we have a match. Only show on the first page of the search
results. This results in a relatively fast experience for someone doing
something like searching for the "perl" package.

Signed-off-by: Dan McGee <dan@archlinux.org>
2014-10-18 18:28:26 -05:00
Dan McGee
28d486870d More changes for move to Django 1.7
The removal of the root `__init__.py` file is so the testing framework
does consistent imports of our models now that the loading strategy has
changed.

Signed-off-by: Dan McGee <dan@archlinux.org>
2014-09-01 18:26:05 -05:00
Dan McGee
ee6002c911 Django 1.6 upgrade, deprecation cleanup
PendingDeprecationWarning: commit_on_success is deprecated in favor of atomic.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-11-06 21:17:27 -06:00
Dan McGee
b7b2474064 Various minor code cleanups and fixes
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-16 22:12:01 -05:00
Dan McGee
31d39e75ee Add shortcut for HEAD requests on slower views
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-16 21:59:32 -05:00
Dan McGee
283cd944be Use require_safe decorator rather than require_GET
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-16 20:16:06 -05:00
Dan McGee
7fc8da7d95 Show replacments for package if it has been removed
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-04-13 13:05:02 -05:00
Dan McGee
dd0ecfaeac Use user.userprofile rather than user.get_profile()
The get_profile() function is deprecated as of Django 1.5.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-26 19:51:40 -06:00
Dan McGee
f85cc0482a Merge branch 'django-1.5'
Conflicts:
	requirements.txt
	requirements_prod.txt
2013-02-26 18:45:14 -06:00
Dan McGee
0491bdb245 Fix some fallout with moving page to query params
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-02-20 00:19:12 -06:00
Dan McGee
746023d529 Make page a query string parameter on package search
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-16 15:39:23 -06:00
Dan McGee
e3837b5a87 Remove configurable pagination for package search
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-16 15:39:23 -06:00
Dan McGee
5566d43a77 Use 'update_fields' model.save() kwarg
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-09 16:50:45 -06:00
Dan McGee
e65c780554 Remove package seach by 'Last Updated After'
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-02-08 21:09:47 -06:00
Dan McGee
dc6cc49f6f Use more modern verison of string template formatting
Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-23 09:20:19 -07:00
Dan McGee
a10798b756 Use querysets for calls to get_object_or_404(Package)
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-23 09:18:59 -07:00
Dan McGee
66850026ca Use content_type and not mimetype on HttpResponse()
Bug #16519 in Django deprecates mimetype, so update our code
accordingly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2013-01-13 22:34:33 -06:00
Dan McGee
2bfdcec869 Make packages JSON search more performant
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>
2013-01-12 16:47:20 -06:00
Dan McGee
9e9157d0a8 Use python set comprehension syntax supported in 2.7
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16 16:37:53 -06:00
Dan McGee
6dd4d54bb0 Use Python 2.7 dictionary comprehension syntax
Rather than the old idiom of dict((k, v) for <> in <>).

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-11-16 16:37:52 -06:00
Dan McGee
2ee662c77c Extract some common architecture grabbing logic
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-10-26 17:05:39 -05:00
Dan McGee
feabc12d38 Fix usage of naïve datetime object
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-30 10:11:19 -05:00
Dan McGee
44dc458a2b Hide staging packages in search results
This is for users that aren't logged in; developers will still see them.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-30 01:40:29 -05:00
Dan McGee
7a0e6620c9 Don't show staging in package search repo listing
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-25 18:22:16 -05:00
Dan McGee
10f5c27bf8 Remove now unnecessary import
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-15 09:46:28 -05:00
Florian Pritz
f2f00b3c04 p/v/flag: Add reply-to to out-of-date notifications
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-09-08 11:11:18 -05:00
Dan McGee
f728962500 Use case-insensitive search in opensearch suggestions
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-20 21:19:02 -05:00
Dan McGee
3cb16e4784 Attempt to screen for useless out-of-date messages
Things like ' ', '-', '.', etc. will no longer be accepted in this
field.

Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-13 21:24:40 -05:00
Dan McGee
b425b192e1 Migrate flag request version info to new format
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-08 22:21:05 -05:00
Dan McGee
f5d3c02eb1 Revert "Fall back to 410 Gone for package files view as well"
This reverts commit 9ab460c53a.

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-07-31 19:49:37 -05:00
Dan McGee
5f85a1240d Reuse removed template for packages with multiple replacements
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-07-31 19:31:44 -05:00
Dan McGee
5f410c000e Add package details redirect for package replacements
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-07-31 19:12:27 -05:00
Dan McGee
0b7939ae1a Rework package details dispatch code
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-31 19:01:45 -05:00
Dan McGee
4ad43fd816 Fix broken hidden input sort field on search form
Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-31 00:26:02 -05:00
Dan McGee
24b28a504c Replace deprecated list_detail usage in search with class-based view
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-24 21:01:31 -05:00
Dan McGee
76c37ce3ac Replace deprecated direct_to_template() with render() shortcut
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-24 19:57:20 -05:00
Dan McGee
c0bf9e2066 Remove custom utc_now() function, use django.utils.timezone.now()
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-24 19:57:20 -05:00
Dan McGee
9ab460c53a Fall back to 410 Gone for package files view as well
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-23 21:47:43 -05:00
Dan McGee
211340c8bd Ensure package files JS can support corner cases
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-23 21:31:17 -05:00
Dan McGee
374bf53505 Remove files list AJAX conditionals
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-23 21:17:02 -05:00
Dan McGee
946d90d08f Add '410 Gone' support for packages moved out of repositories
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-23 09:55:46 -05:00
Dan McGee
872d4bcaa2 Split details/display package views into new module
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-07-21 11:26:34 -05:00
Dan McGee
cf67e79523 Issue redirects from non-agnostic to agnostic URLs if unambiguous
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-18 21:36:05 -05:00
Dan McGee
a5f5557493 Use python json module directly in place of simplejson
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-12 09:32:30 -05:00
Dan McGee
d4c7a48623 Fix suggestion caching again for non-ASCII characters
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-05 10:19:49 -05:00