From e81d36ab05801590343e373fbb97265d84c2fcc5 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 20 Mar 2017 16:38:04 -0300 Subject: templates/news: Add a email template for use in the announce. --- templates/news/news_email_notification.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 templates/news/news_email_notification.txt diff --git a/templates/news/news_email_notification.txt b/templates/news/news_email_notification.txt new file mode 100644 index 00000000..8d9a3d0a --- /dev/null +++ b/templates/news/news_email_notification.txt @@ -0,0 +1,3 @@ +{{ news.content }} + +URL: https://archlinux.org{{ news.get_absolute_url }} -- cgit v1.2.2 From 198f35c3b9c2201fb5f6906e1af8c5d700669d11 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 20 Mar 2017 16:40:00 -0300 Subject: news: Add send_announce to the model Added a new send_announce boolean that controls if an e-mail containing the announce will or not be sent. --- news/migrations/0002_news_send_announce.py | 20 ++++++++++++++++++++ news/models.py | 1 + 2 files changed, 21 insertions(+) create mode 100644 news/migrations/0002_news_send_announce.py diff --git a/news/migrations/0002_news_send_announce.py b/news/migrations/0002_news_send_announce.py new file mode 100644 index 00000000..62c23226 --- /dev/null +++ b/news/migrations/0002_news_send_announce.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('news', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='news', + name='send_announce', + field=models.BooleanField(default=True), + preserve_default=True, + ), + ] diff --git a/news/models.py b/news/models.py index a66da8d4..b413d17b 100644 --- a/news/models.py +++ b/news/models.py @@ -17,6 +17,7 @@ class News(models.Model): guid = models.CharField(max_length=255, editable=False) content = models.TextField() safe_mode = models.BooleanField(default=True) + send_announce = models.BooleanField(default=True) def get_absolute_url(self): return '/news/%s/' % self.slug -- cgit v1.2.2 From c68ae29cc4c16bfff05625c1df106a8a650ca94f Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 20 Mar 2017 17:01:17 -0300 Subject: templates/news: Correct the site url on the template. --- templates/news/news_email_notification.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/news/news_email_notification.txt b/templates/news/news_email_notification.txt index 8d9a3d0a..2588c921 100644 --- a/templates/news/news_email_notification.txt +++ b/templates/news/news_email_notification.txt @@ -1,3 +1,3 @@ {{ news.content }} -URL: https://archlinux.org{{ news.get_absolute_url }} +URL: https://www.archlinux.org{{ news.get_absolute_url }} -- cgit v1.2.2 From fba04673d91707ac33ba24ff3d904ee8764d8745 Mon Sep 17 00:00:00 2001 From: Giancarlo Razzolini Date: Mon, 20 Mar 2017 17:11:02 -0300 Subject: news/views: Send e-mail to arch-announce on news creation When send_announce is True, we send an e-mail to the arch-announce mail list, containing the content of the news and the URL (slug to it). --- news/views.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/news/views.py b/news/views.py index 274ba75d..b5bb4801 100644 --- a/news/views.py +++ b/news/views.py @@ -1,6 +1,8 @@ from django import forms +from django.core.mail import send_mail from django.http import HttpResponse from django.shortcuts import get_object_or_404, redirect +from django.template import Context, loader from django.views.decorators.http import require_POST from django.views.generic import (DetailView, ListView, CreateView, UpdateView, DeleteView) @@ -37,6 +39,16 @@ class NewsCreateView(CreateView): newsitem.author = self.request.user newsitem.slug = find_unique_slug(News, newsitem.title) newsitem.save() + if newsitem.send_announce: + ctx = Context({ + 'news': newsitem, + }) + template = loader.get_template('news/news_email_notification.txt') + send_mail('[arch-announce] %s' % newsitem.title, + template.render(ctx), + 'Arch Linux: Recent news updates: %s ' % newsitem.author.get_full_name(), + ['arch-announce@archlinux.org'], + fail_silently=True) return super(NewsCreateView, self).form_valid(form) -- cgit v1.2.2 From 152c0dc7944fb97bc13b802ca74bf094573b6e78 Mon Sep 17 00:00:00 2001 From: David Thurstenson Date: Mon, 20 Mar 2017 15:45:20 -0500 Subject: Define BOOTIF in extrabootoptions Since this script sets 'ip=dhcp' by default, archiso_pxe_common will fail if more than one network interface exists, and at least one interface cannot be configured by dhcp. Setting BOOTIF will define which interface that archiso_pxe_common should configure, and will cause it to ignore the rest. Fixes https://bugs.archlinux.org/task/50448 --- templates/releng/archlinux.ipxe | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/releng/archlinux.ipxe b/templates/releng/archlinux.ipxe index 8f3dd6e4..c897a786 100644 --- a/templates/releng/archlinux.ipxe +++ b/templates/releng/archlinux.ipxe @@ -9,7 +9,7 @@ imgtrust # initial options set release {{ releases.0 }} -set extrabootoptions ip=dhcp net.ifnames=0 +set extrabootoptions ip=dhcp net.ifnames=0 BOOTIF=01-${netX/mac} set countrycode :main -- cgit v1.2.2 From 5ceff906e0e7b1ab5f1490042a58b4ee21de94cc Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Sun, 2 Apr 2017 08:48:47 +0200 Subject: Use x86_64 instead of dual postfix for ISO image names Fixes FS#53524 and FS#53520 --- releng/models.py | 4 ++-- releng/views.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/releng/models.py b/releng/models.py index c1a82589..66771b32 100644 --- a/releng/models.py +++ b/releng/models.py @@ -139,11 +139,11 @@ class Release(models.Model): return "iso/%s/" % self.version def iso_url(self): - return "iso/%s/archlinux-%s-dual.iso" % (self.version, self.version) + return "iso/%s/archlinux-%s-x86_64.iso" % (self.version, self.version) def magnet_uri(self): query = [ - ('dn', "archlinux-%s-dual.iso" % self.version), + ('dn', "archlinux-%s-x86_64.iso" % self.version), ] if settings.TORRENT_TRACKERS: query.extend(('tr', uri) for uri in settings.TORRENT_TRACKERS) diff --git a/releng/views.py b/releng/views.py index b2bafb49..70be9736 100644 --- a/releng/views.py +++ b/releng/views.py @@ -237,7 +237,7 @@ def release_torrent(request, version): data = b64decode(release.torrent_data.encode('utf-8')) response = HttpResponse(data, content_type='application/x-bittorrent') # TODO: this is duplicated from Release.iso_url() - filename = 'archlinux-%s-dual.iso.torrent' % release.version + filename = 'archlinux-%s-x86_64.iso.torrent' % release.version response['Content-Disposition'] = 'attachment; filename=%s' % filename return response -- cgit v1.2.2 From 2bc7d4cd2d0bb59572bf63f1ad5b2fe7004dd29a Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 15 Feb 2017 19:37:13 +0100 Subject: remove unused newrelic New Relic is not used in production. Signed-off-by: Jelle van der Waa --- archweb.wsgi | 21 ------ newrelic.ini | 212 ----------------------------------------------------------- 2 files changed, 233 deletions(-) delete mode 100644 newrelic.ini diff --git a/archweb.wsgi b/archweb.wsgi index a0d969e7..dc9ed29b 100644 --- a/archweb.wsgi +++ b/archweb.wsgi @@ -12,26 +12,5 @@ os.environ['DJANGO_SETTINGS_MODULE'] = "settings" os.chdir(base_path) -using_newrelic = False -try: - key_path = os.path.join(base_path, "newrelic.key") - if os.path.exists(key_path): - with open(key_path) as keyfile: - key = keyfile.read().strip() - os.environ["NEW_RELIC_LICENSE_KEY"] = key - - import newrelic.agent - from newrelic.api.exceptions import ConfigurationError - try: - newrelic.agent.initialize(os.path.join(base_path, "newrelic.ini")) - using_newrelic = True - except ConfigurationError: - pass -except ImportError: - pass - from django.core.wsgi import get_wsgi_application application = get_wsgi_application() - -if using_newrelic: - application = newrelic.agent.wsgi_application()(application) diff --git a/newrelic.ini b/newrelic.ini deleted file mode 100644 index 72158dc4..00000000 --- a/newrelic.ini +++ /dev/null @@ -1,212 +0,0 @@ -# --------------------------------------------------------------------------- - -# -# This file configures the New Relic Python Agent. -# -# The path to the configuration file should be supplied to the function -# newrelic.agent.initialize() when the agent is being initialized. -# -# The configuration file follows a structure similar to what you would -# find for Microsoft Windows INI files. For further information on the -# configuration file format see the Python ConfigParser documentation at: -# -# http://docs.python.org/library/configparser.html -# -# For further discussion on the behaviour of the Python agent that can -# be configured via this configuration file see: -# -# http://newrelic.com/docs/python/python-agent-configuration -# - -# --------------------------------------------------------------------------- - -# Here are the settings that are common to all environments. - -[newrelic] - -# You must specify the license key associated with your New -# Relic account. This key binds the Python Agent's data to your -# account in the New Relic service. -#license_key = -# NOTE: this is specified by NEW_RELIC_LICENSE_KEY environment variable -# so this file can live in version control. - -# The appplication name. Set this to be the name of your -# application as you would like it to show up in New Relic UI. -# The UI will then auto-map instances of your application into a -# entry on your home dashboard page. -app_name = Archweb - -# When "true", the agent collects performance data about your -# application and reports this data to the New Relic UI at -# newrelic.com. This global switch is normally overridden for -# each environment below. -monitor_mode = true - -# Sets the name of a file to log agent messages to. Useful for -# debugging any issues with the agent. This is not set by -# default as it is not known in advance what user your web -# application processes will run as and where they have -# permission to write to. Whatever you set this to you must -# ensure that the permissions for the containing directory and -# the file itself are correct, and that the user that your web -# application runs as can write to the file. If not able to -# write out a log file, it is also possible to say "stderr" and -# output to standard error output. This would normally result in -# output appearing in your web server log. -#log_file = /tmp/newrelic-python-agent.log - -# Sets the level of detail of messages sent to the log file, if -# a log file location has been provided. Possible values, in -# increasing order of detail, are: "critical", "error", "warning", -# "info" and "debug". When reporting any agent issues to New -# Relic technical support, the most useful setting for the -# support engineers is "debug". However, this can generate a lot -# of information very quickly, so it is best not to keep the -# agent at this level for longer than it takes to reproduce the -# problem you are experiencing. -log_level = info - -# The Python Agent communicates with the New Relic service using -# SSL by default. Note that this does result in an increase in -# CPU overhead, over and above what would occur for a non SSL -# connection, to perform the encryption involved in the SSL -# communication. This work is though done in a distinct thread -# to those handling your web requests, so it should not impact -# response times. You can if you wish revert to using a non SSL -# connection, but this will result in information being sent -# over a plain socket connection and will not be as secure. -ssl = true - -# High Security Mode enforces certain security settings, and -# prevents them from being overridden, so that no sensitive data -# is sent to New Relic. Enabling High Security Mode means that -# SSL is turned on, request parameters are not collected, and SQL -# can not be sent to New Relic in its raw form. To activate High -# Security Mode, it must be set to 'true' in this local .ini -# configuration file AND be set to 'true' in the server-side -# configuration in the New Relic user interface. For details, see -# https://docs.newrelic.com/docs/subscriptions/high-security -high_security = false - -# The Python Agent will attempt to connect directly to the New -# Relic service. If there is an intermediate firewall between -# your host and the New Relic service that requires you to use a -# HTTP proxy, then you should set both the "proxy_host" and -# "proxy_port" settings to the required values for the HTTP -# proxy. The "proxy_user" and "proxy_pass" settings should -# additionally be set if proxy authentication is implemented by -# the HTTP proxy. The "proxy_scheme" setting dictates what -# protocol scheme is used in talking to the HTTP proxy. This -# would normally always be set as "http" which will result in the -# agent then using a SSL tunnel through the HTTP proxy for end to -# end encryption. -# proxy_scheme = http -# proxy_host = hostname -# proxy_port = 8080 -# proxy_user = -# proxy_pass = - -# Tells the transaction tracer and error collector (when -# enabled) whether or not to capture the query string for the -# URL and send it as the request parameters for display in the -# UI. When "true", it is still possible to exclude specific -# values from being captured using the "ignored_params" setting. -capture_params = false - -# Space separated list of variables that should be removed from -# the query string captured for display as the request -# parameters in the UI. -ignored_params = - -# The transaction tracer captures deep information about slow -# transactions and sends this to the UI on a periodic basis. The -# transaction tracer is enabled by default. Set this to "false" -# to turn it off. -transaction_tracer.enabled = true - -# Threshold in seconds for when to collect a transaction trace. -# When the response time of a controller action exceeds this -# threshold, a transaction trace will be recorded and sent to -# the UI. Valid values are any positive float value, or (default) -# "apdex_f", which will use the threshold for a dissatisfying -# Apdex controller action - four times the Apdex T value. -transaction_tracer.transaction_threshold = apdex_f - -# When the transaction tracer is on, SQL statements can -# optionally be recorded. The recorder has three modes, "off" -# which sends no SQL, "raw" which sends the SQL statement in its -# original form, and "obfuscated", which strips out numeric and -# string literals. -transaction_tracer.record_sql = obfuscated - -# Threshold in seconds for when to collect stack trace for a SQL -# call. In other words, when SQL statements exceed this -# threshold, then capture and send to the UI the current stack -# trace. This is helpful for pinpointing where long SQL calls -# originate from in an application. -transaction_tracer.stack_trace_threshold = 0.5 - -# Determines whether the agent will capture query plans for slow -# SQL queries. Only supported in MySQL and PostgreSQL. Set this -# to "false" to turn it off. -transaction_tracer.explain_enabled = true - -# Threshold for query execution time below which query plans -# will not not be captured. Relevant only when "explain_enabled" -# is true. -transaction_tracer.explain_threshold = 0.5 - -# Space separated list of function or method names in form -# 'module:function' or 'module:class.function' for which -# additional function timing instrumentation will be added. -transaction_tracer.function_trace = - -# The error collector captures information about uncaught -# exceptions or logged exceptions and sends them to UI for -# viewing. The error collector is enabled by default. Set this -# to "false" to turn it off. -error_collector.enabled = true - -# To stop specific errors from reporting to the UI, set this to -# a space separated list of the Python exception type names to -# ignore. The exception name should be of the form 'module:class'. -error_collector.ignore_errors = - -# Browser monitoring is the Real User Monitoring feature of the UI. -# For those Python web frameworks that are supported, this -# setting enables the auto-insertion of the browser monitoring -# JavaScript fragments. -browser_monitoring.auto_instrument = false - -# A thread profiling session can be scheduled via the UI when -# this option is enabled. The thread profiler will periodically -# capture a snapshot of the call stack for each active thread in -# the application to construct a statistically representative -# call tree. -thread_profiler.enabled = true - -# --------------------------------------------------------------------------- - -# -# The application environments. These are specific settings which -# override the common environment settings. The settings related to a -# specific environment will be used when the environment argument to the -# newrelic.agent.initialize() function has been defined to be either -# "development", "test", "staging" or "production". -# - -[newrelic:development] -monitor_mode = false - -[newrelic:test] -monitor_mode = false - -[newrelic:staging] -app_name = Archweb (Staging) -monitor_mode = true - -[newrelic:production] -monitor_mode = true - -# --------------------------------------------------------------------------- -- cgit v1.2.2 From 656bd0413e664f7c436f66a5f2fd43508ea66ab1 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 17 Apr 2017 22:07:38 +0200 Subject: Use code tags instead of backticks Signed-off-by: Jelle van der Waa --- templates/public/download.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/public/download.html b/templates/public/download.html index 9116816d..62fb3fae 100644 --- a/templates/public/download.html +++ b/templates/public/download.html @@ -20,9 +20,9 @@

Release Info

The image can be burned to a CD, mounted as an ISO file, - or be directly written to a USB stick using a utility like `dd`. It + or be directly written to a USB stick using a utility like dd. It is intended for new installations only; an existing Arch Linux system - can always be updated with `pacman -Syu`.

+ can always be updated with pacman -Syu.

    {% if release.version %}
  • Current Release: {{ release.version }}
  • {% endif %} -- cgit v1.2.2 From 787915705e3ddebd3df4ca0bcb932c1478813162 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 21:45:07 +0200 Subject: settings: pass when local_settings can't be imported Continue when local_settings can't be imported for an easier test setup. Signed-off-by: Jelle van der Waa --- settings.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/settings.py b/settings.py index 4393e693..8043bc4c 100644 --- a/settings.py +++ b/settings.py @@ -178,8 +178,21 @@ COUNTRIES_OVERRIDE = { 'US': 'United States', } +# Make this unique, and don't share it with anybody. +SECRET_KEY = '00000000000000000000000000000000000000000000000' + +DATABASES = { + 'default': { + 'ENGINE' : 'django.db.backends.sqlite3', + 'NAME' : 'database.db', + }, +} + ## Import local settings -from local_settings import * +try: + from local_settings import * +except ImportError: + pass # Enable caching templates in production environments if not TEMPLATE_DEBUG: -- cgit v1.2.2 From 320f78e6374fd15c2ba09a3505ccdcd5ad950a8a Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 15 Feb 2017 20:02:56 +0100 Subject: Add travisci file Signed-off-by: Jelle van der Waa --- .travis.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..81cef987 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,8 @@ +language: python +python: + - "2.7" +install: "pip install -r requirements.txt" + +script: + - python manage.py collectstatic --noinput + - python manage.py test -- cgit v1.2.2 From e6f3e5aa982b3628603842438bb649c927860dd0 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:38:23 +0200 Subject: devel.reports: remove unused arguments Signed-off-by: Jelle van der Waa --- devel/reports.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/devel/reports.py b/devel/reports.py index 66fbd627..dba982a9 100644 --- a/devel/reports.py +++ b/devel/reports.py @@ -21,19 +21,19 @@ class DeveloperReport(object): self.personal = personal -def old(packages, username): +def old(packages): cutoff = now() - timedelta(days=365 * 2) return packages.filter( build_date__lt=cutoff).order_by('build_date') -def outofdate(packages, username): +def outofdate(packages): cutoff = now() - timedelta(days=30) return packages.filter( flag_date__lt=cutoff).order_by('flag_date') -def big(packages, username): +def big(packages): cutoff = 50 * 1024 * 1024 packages = packages.filter( compressed_size__gte=cutoff).order_by('-compressed_size') @@ -46,7 +46,7 @@ def big(packages, username): return packages -def badcompression(packages, username): +def badcompression(packages): cutoff = 0.90 * F('installed_size') packages = packages.filter(compressed_size__gt=25*1024, installed_size__gt=25*1024, @@ -95,7 +95,7 @@ def uncompressed_info(packages, username): return packages.filter(id__in=set(bad_files)) -def unneeded_orphans(packages, username): +def unneeded_orphans(packages): owned = PackageRelation.objects.all().values('pkgbase') required = Depend.objects.all().values('name') # The two separate calls to exclude is required to do the right thing @@ -103,7 +103,7 @@ def unneeded_orphans(packages, username): pkgname__in=required) -def mismatched_signature(packages, username): +def mismatched_signature(packages): filtered = [] packages = packages.select_related( 'arch', 'repo', 'packager').filter(signature_bytes__isnull=False) @@ -127,7 +127,7 @@ def mismatched_signature(packages, username): return filtered -def signature_time(packages, username): +def signature_time(packages): cutoff = timedelta(hours=24) filtered = [] packages = packages.select_related( -- cgit v1.2.2 From a862e9fc66bee5cb9ff07b62a604d052d51e8265 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:38:45 +0200 Subject: devel.reports: remove unused imports Signed-off-by: Jelle van der Waa --- devel/reports.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devel/reports.py b/devel/reports.py index dba982a9..b754b264 100644 --- a/devel/reports.py +++ b/devel/reports.py @@ -5,7 +5,7 @@ from django.db.models import F from django.template.defaultfilters import filesizeformat from django.utils.timezone import now -from .models import DeveloperKey, UserProfile +from .models import DeveloperKey from main.models import PackageFile from packages.models import PackageRelation, Depend -- cgit v1.2.2 From d8c7ee4f4d27e542b182bdc13cd38b335c638cb4 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:39:34 +0200 Subject: pgp_import: remove unused import Signed-off-by: Jelle van der Waa --- devel/management/commands/pgp_import.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devel/management/commands/pgp_import.py b/devel/management/commands/pgp_import.py index 7a124f77..8eb06d50 100644 --- a/devel/management/commands/pgp_import.py +++ b/devel/management/commands/pgp_import.py @@ -7,7 +7,7 @@ Import keys and signatures from a given GPG keyring. Usage: ./manage.py pgp_import """ -from collections import namedtuple, OrderedDict +from collections import OrderedDict from datetime import datetime import logging from pytz import utc -- cgit v1.2.2 From a3e740aace064dda86aa5989047133284f8b0ba9 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:43:13 +0200 Subject: devel.forms: remove unused variable val Signed-off-by: Jelle van der Waa --- devel/forms.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devel/forms.py b/devel/forms.py index e2b1a7a2..cd50eb50 100644 --- a/devel/forms.py +++ b/devel/forms.py @@ -59,7 +59,7 @@ class NewUserForm(forms.ModelForm): 'alias', 'public_email') for key in keys: self.fields[key] = old[key] - for key, val in old.items(): + for key, _ in old.items(): if key not in keys: self.fields[key] = old[key] -- cgit v1.2.2 From c38db1a8ea3b894af783bef45e73b8cdf1638f15 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:44:31 +0200 Subject: rematch_developers: fix logging not lazy Signed-off-by: Jelle van der Waa --- devel/management/commands/rematch_developers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/devel/management/commands/rematch_developers.py b/devel/management/commands/rematch_developers.py index bbb43df0..8636002a 100644 --- a/devel/management/commands/rematch_developers.py +++ b/devel/management/commands/rematch_developers.py @@ -59,7 +59,7 @@ def match_packager(finder): user = finder.find(packager) if user: mapping[packager] = user - logger.debug(" found user %s" % user.username) + logger.debug(" found user %s", user.username) matched_count += 1 for packager_str, user in mapping.items(): @@ -85,7 +85,7 @@ def match_flagrequest(finder): user = finder.find_by_email(user_email) if user: mapping[user_email] = user - logger.debug(" found user %s" % user.username) + logger.debug(" found user %s", user.username) matched_count += 1 for user_email, user in mapping.items(): -- cgit v1.2.2 From 530c4ab4b52ab3f4e61fcc54652f3946c36c5ed0 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 1 May 2017 22:54:04 +0200 Subject: Describe the setup steps for a debug SMTP server An test setup SMTP server can be used to test actions which require a mail to be sent, for example user creation. --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 7f94626f..1f251647 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,16 @@ packages, you will probably want the following: Alter architecture and repo to get x86\_64 and packages from other repos if needed. +# Testing SMTP server + +To be able to create an account on your test environment an SMTP server is +required. A simple debugging SMTP server can be setup using Python. + + python2 -m smtpd -n -c DebuggingServer localhost:1025 + +In local_settings.py change the EMAIL_HOST to 'localhost' and the EMAIL_PORT to +1025. + # Production Installation Ask someone who knows, or you are going to be in trouble. -- cgit v1.2.2 From aed90d52e36a280264b11a8e8960e4348d5d36fb Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 19 Oct 2016 21:44:11 +0200 Subject: Update to django 1.8 Update django, djang-jinja version. Use TEMPLATES = [] to configure the django templates etc. since the old way will be obsolete. --- requirements.txt | 6 +++--- settings.py | 65 +++++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/requirements.txt b/requirements.txt index 8128b451..864fac3a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,12 @@ -e git+git://github.com/fredj/cssmin.git@master#egg=cssmin -Django==1.7.11 +Django==1.8.18 IPy==0.83 -Jinja2==2.7.3 +Jinja2==2.8 Markdown==2.6.2 MarkupSafe==0.23 bencode==1.0 django-countries==3.3 -django-jinja==1.3.3 +django-jinja==2.2.0 jsmin==2.1.1 pgpdump==1.5 pytz>=2015.4 diff --git a/settings.py b/settings.py index 8043bc4c..2f775f56 100644 --- a/settings.py +++ b/settings.py @@ -45,27 +45,62 @@ LOGIN_REDIRECT_URL = '/' # Set django's User stuff to use our profile model AUTH_PROFILE_MODULE = 'devel.UserProfile' +from os import path +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + #'DIRS': ['%s/templates' % DEPLOY_PATH], + 'DIRS' : [ + path.join(DEPLOY_PATH, 'templates') + ], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.core.context_processors.debug', + 'django.contrib.messages.context_processors.messages', + 'main.context_processors.secure', + ], + } + }, + { + 'BACKEND': 'django_jinja.backend.Jinja2', + 'APP_DIRS': True, + 'DIRS' : [ + path.join(DEPLOY_PATH, 'templates') + ], + 'OPTIONS': { + 'context_processors': [ + 'django.contrib.auth.context_processors.auth', + 'django.core.context_processors.debug', + 'django.contrib.messages.context_processors.messages', + 'main.context_processors.secure', + ], + 'match_extension': '.jinja' + } + } +] # We add a processor to determine if the request is secure or not -TEMPLATE_CONTEXT_PROCESSORS = ( - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.contrib.messages.context_processors.messages', - 'main.context_processors.secure', -) - -TEMPLATE_DIRS = ( +#TEMPLATE_CONTEXT_PROCESSORS = ( +# 'django.contrib.auth.context_processors.auth', +# 'django.core.context_processors.debug', +# 'django.contrib.messages.context_processors.messages', +# 'main.context_processors.secure', +#) + +#TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates". # Always use forward slashes, even on Windows. - '%s/templates' % DEPLOY_PATH, -) +# '%s/templates' % DEPLOY_PATH, +#) -TEMPLATE_LOADERS = ( - 'django_jinja.loaders.FileSystemLoader', - 'django_jinja.loaders.AppLoader', -) +#TEMPLATE_LOADERS = ( +# 'django_jinja.loaders.FileSystemLoader', +# 'django_jinja.loaders.AppLoader', +#) # Send templates matching the following to the Jinja2 engine -DEFAULT_JINJA2_TEMPLATE_EXTENSION = '.jinja' +#DEFAULT_JINJA2_TEMPLATE_EXTENSION = '.jinja' MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', -- cgit v1.2.2 From 2971c0e576054fbd92d45f6ca00aca3e6a13e894 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 19 Oct 2016 22:11:51 +0200 Subject: Cleanup remove old TEMPLATE_ stuff --- settings.py | 48 ++++++++++-------------------------------------- 1 file changed, 10 insertions(+), 38 deletions(-) diff --git a/settings.py b/settings.py index 2f775f56..47962d95 100644 --- a/settings.py +++ b/settings.py @@ -48,59 +48,31 @@ AUTH_PROFILE_MODULE = 'devel.UserProfile' from os import path TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - #'DIRS': ['%s/templates' % DEPLOY_PATH], - 'DIRS' : [ - path.join(DEPLOY_PATH, 'templates') - ], + 'BACKEND': 'django_jinja.backend.Jinja2', 'APP_DIRS': True, + 'DIRS': [ + path.join(DEPLOY_PATH, 'templates/jinja') + ], 'OPTIONS': { - 'context_processors': [ - 'django.contrib.auth.context_processors.auth', - 'django.core.context_processors.debug', - 'django.contrib.messages.context_processors.messages', - 'main.context_processors.secure', - ], + 'match_extension': '.jinja' } }, { - 'BACKEND': 'django_jinja.backend.Jinja2', - 'APP_DIRS': True, - 'DIRS' : [ + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'DIRS': [ path.join(DEPLOY_PATH, 'templates') - ], + ], + 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', 'django.contrib.messages.context_processors.messages', 'main.context_processors.secure', - ], - 'match_extension': '.jinja' + ] } } ] -# We add a processor to determine if the request is secure or not -#TEMPLATE_CONTEXT_PROCESSORS = ( -# 'django.contrib.auth.context_processors.auth', -# 'django.core.context_processors.debug', -# 'django.contrib.messages.context_processors.messages', -# 'main.context_processors.secure', -#) - -#TEMPLATE_DIRS = ( - # Put strings here, like "/home/html/django_templates". - # Always use forward slashes, even on Windows. -# '%s/templates' % DEPLOY_PATH, -#) - -#TEMPLATE_LOADERS = ( -# 'django_jinja.loaders.FileSystemLoader', -# 'django_jinja.loaders.AppLoader', -#) - -# Send templates matching the following to the Jinja2 engine -#DEFAULT_JINJA2_TEMPLATE_EXTENSION = '.jinja' MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', -- cgit v1.2.2 From 7ce890eb18a8d7e17c4eacc760e2cc1ce4608a70 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 19 Oct 2016 22:23:10 +0200 Subject: Dump debug loader for now --- settings.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/settings.py b/settings.py index 47962d95..7f28ec5c 100644 --- a/settings.py +++ b/settings.py @@ -69,7 +69,7 @@ TEMPLATES = [ 'django.core.context_processors.debug', 'django.contrib.messages.context_processors.messages', 'main.context_processors.secure', - ] + ], } } ] @@ -201,13 +201,6 @@ try: except ImportError: pass -# Enable caching templates in production environments -if not TEMPLATE_DEBUG: - TEMPLATE_LOADERS = ( - ('django.template.loaders.cached.Loader', TEMPLATE_LOADERS), - ) - JINJA2_BYTECODE_CACHE_ENABLE = True - # Enable the debug toolbar if requested if DEBUG_TOOLBAR: MIDDLEWARE_CLASSES = \ -- cgit v1.2.2 From 6489bd1a2e6faeff624efa93fa6f1b6f6535ca97 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Fri, 21 Oct 2016 22:19:46 +0200 Subject: Port mirrors to pure django template --- main/templatetags/flags.py | 37 +++++++++++++++++++++++ templates/mirrors/error_table.html | 26 ++++++++++++++++ templates/mirrors/error_table.html.jinja | 24 --------------- templates/mirrors/mirror_details.html | 4 +-- templates/mirrors/mirror_details_urls.html | 38 ++++++++++++++++++++++++ templates/mirrors/mirror_details_urls.html.jinja | 36 ---------------------- templates/mirrors/status.html | 6 ++-- templates/mirrors/status_table.html | 29 ++++++++++++++++++ templates/mirrors/status_table.html.jinja | 28 ----------------- templates/mirrors/url_details_logs.html.jinja | 10 ++++--- 10 files changed, 141 insertions(+), 97 deletions(-) create mode 100644 templates/mirrors/error_table.html delete mode 100644 templates/mirrors/error_table.html.jinja create mode 100644 templates/mirrors/mirror_details_urls.html delete mode 100644 templates/mirrors/mirror_details_urls.html.jinja create mode 100644 templates/mirrors/status_table.html delete mode 100644 templates/mirrors/status_table.html.jinja diff --git a/main/templatetags/flags.py b/main/templatetags/flags.py index 5b356561..d50ee51d 100644 --- a/main/templatetags/flags.py +++ b/main/templatetags/flags.py @@ -1,3 +1,4 @@ +from datetime import timedelta from django import template register = template.Library() @@ -10,4 +11,40 @@ def country_flag(country): return ' ' % ( unicode(country.code).lower(), unicode(country.name)) +@register.filter +def percentage(value, arg=1): + if not value and type(value) != float: + return u'' + new_val = value * 100.0 + return '%.*f%%' % (arg, new_val) + +@register.filter +def duration(value): + if not value and type(value) != timedelta: + return u'' + # does not take microseconds into account + total_secs = value.seconds + value.days * 24 * 3600 + mins = total_secs // 60 + hrs, mins = divmod(mins, 60) + return '%d:%02d' % (hrs, mins) + +@register.filter +def floatvalue(value, arg=2): + if value is None: + return u'' + return '%.*f' % (arg, value) + + +@register.filter +def hours(value): + if not value and type(value) != timedelta: + return u'' + # does not take microseconds into account + total_secs = value.seconds + value.days * 24 * 3600 + mins = total_secs // 60 + hrs, mins = divmod(mins, 60) + if hrs == 1: + return '%d hour' % hrs + return '%d hours' % hrs + # vim: set ts=4 sw=4 et: diff --git a/templates/mirrors/error_table.html b/templates/mirrors/error_table.html new file mode 100644 index 00000000..03de4944 --- /dev/null +++ b/templates/mirrors/error_table.html @@ -0,0 +1,26 @@ +{% load flags %} + + + + + + + + + + + + + + + {% for log in error_logs %} + + + + + + + + {% endfor %} + +
    Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
    {{ log.url.url }}{{ log.url.protocol.protocol }}{% country_flag log.url.country %}{{ log.url.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date:'Y-m-d H:i' }}{{ log.error_count }}details
    diff --git a/templates/mirrors/error_table.html.jinja b/templates/mirrors/error_table.html.jinja deleted file mode 100644 index 132aae63..00000000 --- a/templates/mirrors/error_table.html.jinja +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - {% for log in error_logs %} - - - - - - - - {% endfor %} - -
    Mirror URLProtocolCountryError MessageLast OccurredOccurrences (last {{ cutoff|hours }})
    {{ log.url.url }}{{ log.url.protocol.protocol }}{{ country_flag(log.url.country) }}{{ log.url.country.name }}{{ log.error|linebreaksbr }}{{ log.last_occurred|date('Y-m-d H:i') }}{{ log.error_count }}details
    diff --git a/templates/mirrors/mirror_details.html b/templates/mirrors/mirror_details.html index 64009380..401a57e7 100644 --- a/templates/mirrors/mirror_details.html +++ b/templates/mirrors/mirror_details.html @@ -93,10 +93,10 @@

    Available URLs

    - {% include "mirrors/mirror_details_urls.html.jinja" %} + {% include "mirrors/mirror_details_urls.html" %}

    Error Log

    - {% include "mirrors/error_table.html.jinja" %} + {% include "mirrors/error_table.html" %}
    diff --git a/templates/mirrors/mirror_details_urls.html b/templates/mirrors/mirror_details_urls.html new file mode 100644 index 00000000..4cada31e --- /dev/null +++ b/templates/mirrors/mirror_details_urls.html @@ -0,0 +1,38 @@ +{% load flags %} + + + + + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + + + + + + {% endfor %} + +
    Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
    {% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{% country_flag m_url.country %}{{ m_url.country.name }}{{ m_url.has_ipv4|yesno|capfirst }}{{ m_url.has_ipv6|yesno|capfirst }}{{ m_url.last_sync|date:'Y-m-d H:i'|default:'unknown' }}{{ m_url.completion_pct|percentage:1 }}{{ m_url.delay|duration|default:'unknown' }}{{ m_url.duration_avg|floatvalue:2 }}{{ m_url.duration_stddev|floatvalue:2 }}{{ m_url.score|floatvalue:1|default:'∞' }}Details
    diff --git a/templates/mirrors/mirror_details_urls.html.jinja b/templates/mirrors/mirror_details_urls.html.jinja deleted file mode 100644 index 7ab1548b..00000000 --- a/templates/mirrors/mirror_details_urls.html.jinja +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - - - - - - {% endfor %} - -
    Mirror URLProtocolCountryIPv4IPv6Last SyncCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)ScoreDetails
    {% if m_url.protocol.is_download %}{{ m_url.url }}{% else %}{{ m_url.url }}{% endif %}{{ m_url.protocol }}{{ country_flag(m_url.country) }}{{ m_url.country.name }}{{ m_url.has_ipv4|yesno|capfirst }}{{ m_url.has_ipv6|yesno|capfirst }}{{ m_url.last_sync|date('Y-m-d H:i')|default('unknown') }}{{ m_url.completion_pct|percentage(1) }}{{ m_url.delay|duration|default('unknown') }}{{ m_url.duration_avg|floatvalue(2) }}{{ m_url.duration_stddev|floatvalue(2) }}{{ m_url.score|floatvalue(1)|default('∞') }}Details
    diff --git a/templates/mirrors/status.html b/templates/mirrors/status.html index 530e3ff5..24408be7 100644 --- a/templates/mirrors/status.html +++ b/templates/mirrors/status.html @@ -60,18 +60,18 @@

    Out of Sync Mirrors

    {% with urls=bad_urls table_id='outofsync_mirrors' %} - {% include "mirrors/status_table.html.jinja" %} + {% include "mirrors/status_table.html" %} {% endwith %}

    Successfully Syncing Mirrors

    {% with urls=good_urls table_id='successful_mirrors' %} - {% include "mirrors/status_table.html.jinja" %} + {% include "mirrors/status_table.html" %} {% endwith %}

    Mirror Syncing Error Log

    - {% include "mirrors/error_table.html.jinja" %} + {% include "mirrors/error_table.html" %}
    {% endblock %} diff --git a/templates/mirrors/status_table.html b/templates/mirrors/status_table.html new file mode 100644 index 00000000..3f8cd2d9 --- /dev/null +++ b/templates/mirrors/status_table.html @@ -0,0 +1,29 @@ +{% load flags %} + + + + + + + + + + + + + + + + {% for m_url in urls %} + + + + + + + + + + {% endfor %} + +
    Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
    {{ m_url.url }}{{ m_url.protocol }}{% country_flag m_url.country %}{{ m_url.country.name }}{{ m_url.completion_pct|percentage:1 }}{{ m_url.delay|duration|default:unknown }}{{ m_url.duration_avg|floatvalue:2 }}{{ m_url.duration_stddev|floatvalue:2 }}{{ m_url.score|floatvalue:1|default:'∞' }}details
    diff --git a/templates/mirrors/status_table.html.jinja b/templates/mirrors/status_table.html.jinja deleted file mode 100644 index 598a1af0..00000000 --- a/templates/mirrors/status_table.html.jinja +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - {% for m_url in urls %} - - - - - - - - - - {% endfor %} - -
    Mirror URLProtocolCountryCompletion %μ Delay (hh:mm)μ Duration (s)σ Duration (s)Mirror Score
    {{ m_url.url }}{{ m_url.protocol }}{{ country_flag(m_url.country) }}{{ m_url.country.name }}{{ m_url.completion_pct|percentage(1) }}{{ m_url.delay|duration|default('unknown') }}{{ m_url.duration_avg|floatvalue(2) }}{{ m_url.duration_stddev|floatvalue(2) }}{{ m_url.score|floatvalue(1)|default('∞') }}details
    diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja index 51f54931..a87e58d4 100644 --- a/templates/mirrors/url_details_logs.html.jinja +++ b/templates/mirrors/url_details_logs.html.jinja @@ -1,3 +1,5 @@ +{% load flags %} + @@ -12,11 +14,11 @@ - {% for log in logs %} - - + {% for log in logs %} + + - + -- cgit v1.2.2 From 5e56e7ff220971c6865f58eb18040ae7e6404c39 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 30 Nov 2016 20:10:35 +0100 Subject: sitemap: port jinja templates to django Port the .jinja templates to pure django templates --- templates/sitemaps/news_sitemap.xml | 14 ++++++++++++++ templates/sitemaps/news_sitemap.xml.jinja | 14 -------------- templates/sitemaps/sitemap.xml | 9 +++++++++ templates/sitemaps/sitemap.xml.jinja | 9 --------- urls.py | 4 ++-- 5 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 templates/sitemaps/news_sitemap.xml delete mode 100644 templates/sitemaps/news_sitemap.xml.jinja create mode 100644 templates/sitemaps/sitemap.xml delete mode 100644 templates/sitemaps/sitemap.xml.jinja diff --git a/templates/sitemaps/news_sitemap.xml b/templates/sitemaps/news_sitemap.xml new file mode 100644 index 00000000..1492ecce --- /dev/null +++ b/templates/sitemaps/news_sitemap.xml @@ -0,0 +1,14 @@ + + +{% for url in urlset %} +{{ url.location }} +{% if url.lastmod %}{{ url.lastmod|date:"Y-m-d" }}{% endif %} +{% if url.changefreq %}{{ url.changefreq }}{% endif %} +{% if url.priority %}{{ url.priority }}{% endif %} + + Arch Linux Newsen + {% if url.item.postdate %}{{ url.item.postdate|date:"c" }}{% endif %} + {% if url.item.title %}{{ url.item.title }}{% endif %} + +{% endfor %} + diff --git a/templates/sitemaps/news_sitemap.xml.jinja b/templates/sitemaps/news_sitemap.xml.jinja deleted file mode 100644 index 97dd17b5..00000000 --- a/templates/sitemaps/news_sitemap.xml.jinja +++ /dev/null @@ -1,14 +0,0 @@ - - -{% for url in urlset %} -{{ url.location }} -{% if url.lastmod %}{{ url.lastmod|date("Y-m-d") }}{% endif %} -{% if url.changefreq %}{{ url.changefreq }}{% endif %} -{% if url.priority %}{{ url.priority }}{% endif %} - - Arch Linux Newsen - {% if url.item.postdate %}{{ url.item.postdate|date("c") }}{% endif %} - {% if url.item.title %}{{ url.item.title }}{% endif %} - -{% endfor %} - diff --git a/templates/sitemaps/sitemap.xml b/templates/sitemaps/sitemap.xml new file mode 100644 index 00000000..50a95237 --- /dev/null +++ b/templates/sitemaps/sitemap.xml @@ -0,0 +1,9 @@ + + +{% for url in urlset %} +{{ url.location }} +{% if url.lastmod %}{{ url.lastmod|date:"Y-m-d" }}{% endif %} +{% if url.changefreq %}{{ url.changefreq }}{% endif %} +{% if url.priority %}{{ url.priority }}{% endif %} +{% endfor %} + diff --git a/templates/sitemaps/sitemap.xml.jinja b/templates/sitemaps/sitemap.xml.jinja deleted file mode 100644 index 0808a7de..00000000 --- a/templates/sitemaps/sitemap.xml.jinja +++ /dev/null @@ -1,9 +0,0 @@ - - -{% for url in urlset %} -{{ url.location }} -{% if url.lastmod %}{{ url.lastmod|date("Y-m-d") }}{% endif %} -{% if url.changefreq %}{{ url.changefreq }}{% endif %} -{% if url.priority %}{{ url.priority }}{% endif %} -{% endfor %} - diff --git a/urls.py b/urls.py index 76271ece..134ce33e 100644 --- a/urls.py +++ b/urls.py @@ -84,11 +84,11 @@ urlpatterns += patterns('', {'sitemaps': our_sitemaps, 'sitemap_url_name': 'sitemaps'}), (r'^sitemap-(?P
    .+)\.xml$', cache_page(1831)(sitemap_views.sitemap), - {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml.jinja'}, + {'sitemaps': our_sitemaps, 'template_name': 'sitemaps/sitemap.xml'}, 'sitemaps'), (r'^news-sitemap\.xml$', cache_page(1831)(sitemap_views.sitemap), - {'sitemaps': news_sitemaps, 'template_name': 'sitemaps/news_sitemap.xml.jinja'}, + {'sitemaps': news_sitemaps, 'template_name': 'sitemaps/news_sitemap.xml'}, 'news-sitemap'), ) -- cgit v1.2.2 From 0b714e47d27d1a5f32635f144c7ad1f7bc1635a2 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 30 Nov 2016 21:37:39 +0100 Subject: reporead: transaction.set_dirty call --- devel/management/commands/reporead.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/devel/management/commands/reporead.py b/devel/management/commands/reporead.py index 70526bfd..41bbdc72 100644 --- a/devel/management/commands/reporead.py +++ b/devel/management/commands/reporead.py @@ -333,7 +333,8 @@ def update_common(archname, reponame, pkgs, sanity_check=True): # necessary to guard against simultaneous updates. with transaction.atomic(): # force the transaction dirty, even though we will only do reads - transaction.set_dirty() + # https://github.com/django/django/blob/3c447b108ac70757001171f7a4791f493880bf5b/docs/releases/1.3.txt#L606 + #transaction.set_dirty() repository = Repo.objects.get(name__iexact=reponame) architecture = Arch.objects.get(name=archname) -- cgit v1.2.2 From 9ae767cb4faf8d8d58630cd4716d946abcc9653a Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 30 Nov 2016 21:40:31 +0100 Subject: port templates/packages to pure django --- main/templatetags/details_link.py | 77 ++++++++ templates/packages/details.html | 2 +- templates/packages/details.html.jinja | 223 ----------------------- templates/packages/details_depend.html | 13 ++ templates/packages/details_depend.html.jinja | 13 -- templates/packages/details_link.html | 1 + templates/packages/details_link.html.jinja | 1 - templates/packages/details_relatedto.html | 3 + templates/packages/details_relatedto.html.jinja | 3 - templates/packages/details_requiredby.html | 8 + templates/packages/details_requiredby.html.jinja | 8 - templates/packages/package_details.html | 223 +++++++++++++++++++++++ 12 files changed, 326 insertions(+), 249 deletions(-) create mode 100644 main/templatetags/details_link.py delete mode 100644 templates/packages/details.html.jinja create mode 100644 templates/packages/details_depend.html delete mode 100644 templates/packages/details_depend.html.jinja create mode 100644 templates/packages/details_link.html delete mode 100644 templates/packages/details_link.html.jinja create mode 100644 templates/packages/details_relatedto.html delete mode 100644 templates/packages/details_relatedto.html.jinja create mode 100644 templates/packages/details_requiredby.html delete mode 100644 templates/packages/details_requiredby.html.jinja create mode 100644 templates/packages/package_details.html diff --git a/main/templatetags/details_link.py b/main/templatetags/details_link.py new file mode 100644 index 00000000..b94f8487 --- /dev/null +++ b/main/templatetags/details_link.py @@ -0,0 +1,77 @@ +from urllib import urlencode, quote as urlquote, unquote +from django import template +from main.templatetags import pgp + +register = template.Library() + + +def link_encode(url, query): + # massage the data into all utf-8 encoded strings first, so urlencode + # doesn't barf at the data we pass it + query = {k: unicode(v).encode('utf-8') for k, v in query.items()} + data = urlencode(query) + return "%s?%s" % (url, data) + + +@register.inclusion_tag('packages/details_link.html') +def details_link(pkg): + return {'pkg': pkg} + + +@register.simple_tag +def scm_link(package, operation): + parts = (package.repo.svn_root, operation, package.pkgbase) + linkbase = ( + "https://projects.archlinux.org/svntogit/%s.git/%s/trunk?" + "h=packages/%s") + return linkbase % tuple(urlquote(part.encode('utf-8')) for part in parts) + + +@register.simple_tag +def bugs_list(package): + url = "https://bugs.archlinux.org/" + data = { + 'project': package.repo.bugs_project, + 'cat[]': package.repo.bugs_category, + 'string': package.pkgname, + } + return link_encode(url, data) + + +@register.simple_tag +def bug_report(package): + url = "https://bugs.archlinux.org/newtask" + data = { + 'project': package.repo.bugs_project, + 'product_category': package.repo.bugs_category, + 'item_summary': '[%s] PLEASE ENTER SUMMARY' % package.pkgname, + } + return link_encode(url, data) + + +@register.simple_tag +def wiki_link(package): + url = "https://wiki.archlinux.org/index.php/Special:Search" + data = { + 'search': package.pkgname, + } + return link_encode(url, data) + + +@register.simple_tag +def pgp_key_link(key_id, link_text=None): + return pgp.pgp_key_link(key_id, link_text) + + +@register.filter +def url_unquote(original_url): + try: + url = original_url + if isinstance(url, unicode): + url = url.encode('ascii') + url = unquote(url).decode('utf-8') + return url + except UnicodeError: + return original_url + +# vim: set ts=4 sw=4 et: diff --git a/templates/packages/details.html b/templates/packages/details.html index 7a0f8e88..2851abd6 100644 --- a/templates/packages/details.html +++ b/templates/packages/details.html @@ -5,7 +5,7 @@ {% block navbarclass %}anb-packages{% endblock %} {% block content %} -{% include "packages/details.html.jinja" %} +{% include "packages/package_details.html" %} {% endblock %} {% block script_block %} diff --git a/templates/packages/details.html.jinja b/templates/packages/details.html.jinja deleted file mode 100644 index 9a72622d..00000000 --- a/templates/packages/details.html.jinja +++ /dev/null @@ -1,223 +0,0 @@ -{% import 'packages/details_link.html.jinja' as details %} -
    -

    {{ pkg.pkgname }} {{ pkg.full_version }}

    - - - -
    - - - - - - - - {% if pkg.packager %}
    - -
    {% endif %} -
    {{ log.check_time|date('Y-m-d H:i') }}{% if log.location %}{{ country_flag(log.location.country) }}{{ log.location.country.name }}{% else %}Unknown{% endif %}
    {{ log.check_time|date:'Y-m-d H:i' }}{% if log.location %}{% country_flag log.location.country %}{{ log.location.country.name }}{% else %}Unknown{% endif %} {% if log.location %}{{ log.location.source_ip }}{% else %}Unknown{% endif %}{{ log.last_sync|date('Y-m-d H:i') }}{{ log.last_sync|date:'Y-m-d H:i' }} {{ log.delay|duration }} {{ log.duration|floatvalue }} {{ log.is_success|yesno|capfirst }}
    - - - - - - - - {% if pkg.pkgname == pkg.pkgbase %} - {% with splits = pkg.split_packages() %}{% if splits %} - - - - - {% endif %}{% endwith %} - {% else %} - - - {% with base = pkg.base_package() %}{% if base %} - - {% else %} - - {% endif %}{% endwith %} - - {% endif %} - - - - - - - - - - - {% with groups = pkg.groups.all() %}{% if groups %} - - - - - {% endif %}{% endwith %} - {% with all_related = pkg.provides.all() %}{% if all_related %} - - - - - {% endif %}{% endwith %} - {% with all_related = pkg.replaces.all() %}{% if all_related %} - - - - - {% endif %}{% endwith %} - {% with all_related = pkg.conflicts.all() %}{% if all_related %} - - - - - {% endif %}{% endwith %} - {% with rev_conflicts = pkg.reverse_conflicts() %}{% if rev_conflicts %} - - - - - {% endif %}{% endwith %} - - - {% with maints = pkg.maintainers %} - - {% endwith %} - - - - - - - - - - - - - {% if pkg.signature %} - - - - - - {% else %} - - - {% endif %} - - - - {% if user.is_authenticated() %}{% with flag_request = pkg.flag_request() %}{% if flag_request %} - - - {% endif %}{% endwith %}{% endif %} -
    Architecture:{{ pkg.arch.name }}
    Repository:{{ pkg.repo.name|capfirst }}
    Split Packages:{% for s in splits %}{{ details.details_link(s) }}{% if not loop.last %}, {% endif %}{% endfor %}
    Base Package:{{ details.details_link(base) }}{{ pkg.pkgbase }}
    Description:{{ pkg.pkgdesc|default("", true) }}
    Upstream URL:{% if pkg.url %}{% endif %}
    License(s):{{ pkg.licenses.all()|join(", ") }}
    Groups:{% for g in groups %} - {{ g.name }}{% if not loop.last %}, {% endif %}{% endfor %} -
    Provides:{% include "packages/details_relatedto.html.jinja" %}
    Replaces:{% include "packages/details_relatedto.html.jinja" %}
    Conflicts:{% include "packages/details_relatedto.html.jinja" %}
    Reverse Conflicts:{% for conflict in rev_conflicts %} - {{ details.details_link(conflict) }}{% if not loop.last %}, {% endif %}{% endfor %}
    Maintainers:{% if maints %}{% for m in maints %} - {{ m.get_full_name() }}
    - {% endfor %}{% else %}Orphan{% endif %} -
    Package Size:{{ pkg.compressed_size|filesizeformat }}
    Installed Size:{{ pkg.installed_size|filesizeformat }}
    Last Packager:{% with pkgr = pkg.packager %}{% if pkgr %} - {{ pkgr.get_full_name() }} - {% else %}{{ pkg.packager_str }}{% endif %}{% endwith %}
    Build Date:{{ pkg.build_date|date("DATETIME_FORMAT") }} UTC
    Signed By:{% with signer = pkg.signer %}{% if signer %}{{ pgp_key_link(pkg.signature.key_id, signer.get_full_name())|safe }}{% else %}Unknown ({{ pgp_key_link(pkg.signature.key_id)|safe }}){% endif %}{% endwith %}
    Signature Date:{{ pkg.signature.creation_time|date("DATETIME_FORMAT") }} UTC
    Signed By:Unsigned
    Last Updated:{{ pkg.last_update|date("DATETIME_FORMAT") }} UTC
    Last Flag Request:From {{ flag_request.who() }} on {{ flag_request.created|date }}:
    -
    {{ flag_request.message|linebreaksbr|default("{no message}", true) }}
    - - -
    - {% with deps = pkg.get_depends() %} -
    -

    - Dependencies ({{deps|length}})

    - {% if deps %}
      - {% for depend in deps %}{% include "packages/details_depend.html.jinja" %}{% endfor %} -
    {% endif %} -
    - {% endwith %} - {% with rqdby = pkg.get_requiredby() %} -
    -

    - Required By ({{rqdby|length}})

    - {% if rqdby %}
      - {% for req in rqdby %}{% include "packages/details_requiredby.html.jinja" %}{% endfor %} -
    {% endif %} -
    - {% endwith %} -
    -

    - Package Contents

    - -
    -
    - diff --git a/templates/packages/details_depend.html b/templates/packages/details_depend.html new file mode 100644 index 00000000..5e27374b --- /dev/null +++ b/templates/packages/details_depend.html @@ -0,0 +1,13 @@ +{% load details_link %}
  • {% if depend.pkg == None %} +{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} ({% for pkg in depend.providers %}{% details_link pkg %}{% if not loop.last %}, {% endif %}{% endfor %}) +{% else %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} (virtual) +{% endif %}{% else %} +{% details_link depend.pkg %}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} +{% if depend.pkg.repo.testing %} (testing) +{% endif %}{% if depend.pkg.repo.staging %} (staging) +{% endif %}{% endif %} +{% if depend.dep.deptype == 'O' %} (optional) +{% endif %}{% if depend.dep.deptype == 'M' %} (make) +{% endif %}{% if depend.dep.deptype == 'C' %} (check) +{% endif %}{% if depend.dep.description %} - {{ depend.dep.description }} +{% endif %}
  • diff --git a/templates/packages/details_depend.html.jinja b/templates/packages/details_depend.html.jinja deleted file mode 100644 index a2d3a010..00000000 --- a/templates/packages/details_depend.html.jinja +++ /dev/null @@ -1,13 +0,0 @@ -{% import 'packages/details_link.html.jinja' as details %}
  • {% if depend.pkg == None %} -{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default("", true) }}{{ depend.dep.version|default("", true) }} ({% for pkg in depend.providers %}{{ details.details_link(pkg) }}{% if not loop.last %}, {% endif %}{% endfor %}) -{% else %}{{ depend.dep.name }}{{ depend.dep.comparison|default("", true) }}{{ depend.dep.version|default("", true) }} (virtual) -{% endif %}{% else %} -{{ details.details_link(depend.pkg) }}{{ depend.dep.comparison|default("", true) }}{{ depend.dep.version|default("", true) }} -{% if depend.pkg.repo.testing %} (testing) -{% endif %}{% if depend.pkg.repo.staging %} (staging) -{% endif %}{% endif %} -{% if depend.dep.deptype == 'O' %} (optional) -{% endif %}{% if depend.dep.deptype == 'M' %} (make) -{% endif %}{% if depend.dep.deptype == 'C' %} (check) -{% endif %}{% if depend.dep.description %} - {{ depend.dep.description }} -{% endif %}
  • diff --git a/templates/packages/details_link.html b/templates/packages/details_link.html new file mode 100644 index 00000000..87d66d6a --- /dev/null +++ b/templates/packages/details_link.html @@ -0,0 +1 @@ +{{ pkg.pkgname }} diff --git a/templates/packages/details_link.html.jinja b/templates/packages/details_link.html.jinja deleted file mode 100644 index b7e75fe5..00000000 --- a/templates/packages/details_link.html.jinja +++ /dev/null @@ -1 +0,0 @@ -{% macro details_link(pkg) %}{{ pkg.pkgname }}{% endmacro %} diff --git a/templates/packages/details_relatedto.html b/templates/packages/details_relatedto.html new file mode 100644 index 00000000..c22dfb7f --- /dev/null +++ b/templates/packages/details_relatedto.html @@ -0,0 +1,3 @@ +{% load details_link %}{% for related in all_related %}{% with best_satisfier=related.get_best_satisfier %} +{% if best_satisfier == None %}{{ related.name }}{% else %}{% details_link best_satisfier %}{% endif %}{{ related.comparison|default:'' }}{{ related.version|default:'' }}{% if not loop.last %}, {% endif %} +{% endwith %}{% endfor %} diff --git a/templates/packages/details_relatedto.html.jinja b/templates/packages/details_relatedto.html.jinja deleted file mode 100644 index 818224de..00000000 --- a/templates/packages/details_relatedto.html.jinja +++ /dev/null @@ -1,3 +0,0 @@ -{% import 'packages/details_link.html.jinja' as details %}{% for related in all_related %}{% with best_satisfier = related.get_best_satisfier() %} -{% if best_satisfier == None %}{{ related.name }}{% else %}{{ details.details_link(best_satisfier) }}{% endif %}{{ related.comparison|default('', true) }}{{ related.version|default('', true) }}{% if not loop.last %}, {% endif %} -{% endwith %}{% endfor %} diff --git a/templates/packages/details_requiredby.html b/templates/packages/details_requiredby.html new file mode 100644 index 00000000..c8084649 --- /dev/null +++ b/templates/packages/details_requiredby.html @@ -0,0 +1,8 @@ +{% load details_link %}
  • {% details_link req.pkg %} +{% if req.name != pkg.pkgname %} (requires {{ req.name }}) +{% endif %}{% if req.pkg.repo.testing %} (testing) +{% endif %}{% if req.pkg.repo.staging %} (staging) +{% endif %}{% if req.deptype == 'O' %} (optional) +{% endif %}{% if req.deptype == 'M' %} (make) +{% endif %}{% if req.deptype == 'C' %} (check) +{% endif %}
  • diff --git a/templates/packages/details_requiredby.html.jinja b/templates/packages/details_requiredby.html.jinja deleted file mode 100644 index b083a7fc..00000000 --- a/templates/packages/details_requiredby.html.jinja +++ /dev/null @@ -1,8 +0,0 @@ -{% import 'packages/details_link.html.jinja' as details %}
  • {{ details.details_link(req.pkg) }} -{% if req.name != pkg.pkgname %} (requires {{ req.name }}) -{% endif %}{% if req.pkg.repo.testing %} (testing) -{% endif %}{% if req.pkg.repo.staging %} (staging) -{% endif %}{% if req.deptype == 'O' %} (optional) -{% endif %}{% if req.deptype == 'M' %} (make) -{% endif %}{% if req.deptype == 'C' %} (check) -{% endif %}
  • diff --git a/templates/packages/package_details.html b/templates/packages/package_details.html new file mode 100644 index 00000000..c0a066f2 --- /dev/null +++ b/templates/packages/package_details.html @@ -0,0 +1,223 @@ +{% load details_link %} +
    +

    {{ pkg.pkgname }} {{ pkg.full_version }}

    + + + +
    + + + + + + + + {% if pkg.packager %}
    + +
    {% endif %} + + + + + + + + + {% if pkg.pkgname == pkg.pkgbase %} + {% with splits=pkg.split_packages %}{% if splits %} + + + + + {% endif %}{% endwith %} + {% else %} + + + {% with base=pkg.base_package %}{% if base %} + + {% else %} + + {% endif %}{% endwith %} + + {% endif %} + + + + + + + + + + + {% with groups=pkg.groups.all %}{% if groups %} + + + + + {% endif %}{% endwith %} + {% with all_related=pkg.provides.all %}{% if all_related %} + + + + + {% endif %}{% endwith %} + {% with all_related=pkg.replaces.all %}{% if all_related %} + + + + + {% endif %}{% endwith %} + {% with all_related=pkg.conflicts.all %}{% if all_related %} + + + + + {% endif %}{% endwith %} + {% with rev_conflicts=pkg.reverse_conflicts %}{% if rev_conflicts %} + + + + + {% endif %}{% endwith %} + + + {% with maints=pkg.maintainers %} + + {% endwith %} + + + + + + + + + + + + + {% if pkg.signature %} + + + + + + {% else %} + + + {% endif %} + + + + {% if user.is_authenticated %}{% with flag_request=pkg.flag_request %}{% if flag_request %} + + + {% endif %}{% endwith %}{% endif %} +
    Architecture:{{ pkg.arch.name }}
    Repository:{{ pkg.repo.name|capfirst }}
    Split Packages:{% for s in splits %}{% details_link s %}{% if not loop.last %}, {% endif %}{% endfor %}
    Base Package:{% details_link base %}{{ pkg.pkgbase }}
    Description:{{ pkg.pkgdesc|default:"" }}
    Upstream URL:{% if pkg.url %}{% endif %}
    License(s):{{ pkg.licenses.all|join:", " }}
    Groups:{% for g in groups %} + {{ g.name }}{% if not loop.last %}, {% endif %}{% endfor %} +
    Provides:{% include "packages/details_relatedto.html" %}
    Replaces:{% include "packages/details_relatedto.html" %}
    Conflicts:{% include "packages/details_relatedto.html" %}
    Reverse Conflicts:{% for conflict in rev_conflicts %} + {% details_link conflict %}{% if not loop.last %}, {% endif %}{% endfor %}
    Maintainers:{% if maints %}{% for m in maints %} + {{ m.get_full_name }}
    + {% endfor %}{% else %}Orphan{% endif %} +
    Package Size:{{ pkg.compressed_size|filesizeformat }}
    Installed Size:{{ pkg.installed_size|filesizeformat }}
    Last Packager:{% with pkgr=pkg.packager %}{% if pkgr %} + {{ pkgr.get_full_name }} + {% else %}{{ pkg.packager_str }}{% endif %}{% endwith %}
    Build Date:{{ pkg.build_date|date:"DATETIME_FORMAT" }} UTC
    Signed By:{% with signer=pkg.signer %}{% if signer %}{% pgp_key_link pkg.signature.key_id signer.get_full_name|safe %}{% else %}Unknown ({% pgp_key_link pkg.signature.key_id|safe %}){% endif %}{% endwith %}
    Signature Date:{{ pkg.signature.creation_time|date:"DATETIME_FORMAT" }} UTC
    Signed By:Unsigned
    Last Updated:{{ pkg.last_update|date:"DATETIME_FORMAT" }} UTC
    Last Flag Request:From {{ flag_request.who }} on {{ flag_request.created|date }}:
    +
    {{ flag_request.message|linebreaksbr|default:"{no message}" }}
    +
    + +
    + {% with deps=pkg.get_depends %} +
    +

    + Dependencies ({{deps|length}})

    + {% if deps %}
      + {% for depend in deps %}{% include "packages/details_depend.html" %}{% endfor %} +
    {% endif %} +
    + {% endwith %} + {% with rqdby=pkg.get_requiredby %} +
    +

    + Required By ({{rqdby|length}})

    + {% if rqdby %}
      + {% for req in rqdby %}{% include "packages/details_requiredby.html" %}{% endfor %} +
    {% endif %} +
    + {% endwith %} +
    +

    + Package Contents

    + +
    +
    +
    -- cgit v1.2.2 From 8841e3f7f3b002526f0dad3bf0762b10f451bcba Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 30 Nov 2016 21:53:09 +0100 Subject: templates: port files to django template --- templates/packages/files.html | 2 +- templates/packages/files_list.html | 16 ++++++++++++++++ templates/packages/files_list.html.jinja | 16 ---------------- 3 files changed, 17 insertions(+), 17 deletions(-) create mode 100644 templates/packages/files_list.html delete mode 100644 templates/packages/files_list.html.jinja diff --git a/templates/packages/files.html b/templates/packages/files.html index 879fcbff..3e718ed0 100644 --- a/templates/packages/files.html +++ b/templates/packages/files.html @@ -9,7 +9,7 @@

    Package has {{ files_count }} file{{ files_count|pluralize }} and {{ dir_count }} director{{ dir_count|pluralize:"y,ies" }}.

    Back to Package

    - {% include "packages/files_list.html.jinja" %} + {% include "packages/files_list.html" %}
    diff --git a/templates/packages/files_list.html b/templates/packages/files_list.html new file mode 100644 index 00000000..ab3e1210 --- /dev/null +++ b/templates/packages/files_list.html @@ -0,0 +1,16 @@ +{% if pkg.last_update > pkg.files_last_update %} +

    Note: This file list was generated from a previous version +of the package; it may be out of date.

    +{% endif %} +{% if pkg.files_last_update %} +{% if files|length %} +
      +{% for file in files %} +
    • {{ file.directory }}{{ file.filename|default('', true) }}
    • {% endfor %} +
    +{% else %} +

    Package has no files.

    +{% endif %} +{% else %} +

    No file list available.

    +{% endif %} diff --git a/templates/packages/files_list.html.jinja b/templates/packages/files_list.html.jinja deleted file mode 100644 index ab3e1210..00000000 --- a/templates/packages/files_list.html.jinja +++ /dev/null @@ -1,16 +0,0 @@ -{% if pkg.last_update > pkg.files_last_update %} -

    Note: This file list was generated from a previous version -of the package; it may be out of date.

    -{% endif %} -{% if pkg.files_last_update %} -{% if files|length %} -
      -{% for file in files %} -
    • {{ file.directory }}{{ file.filename|default('', true) }}
    • {% endfor %} -
    -{% else %} -

    Package has no files.

    -{% endif %} -{% else %} -

    No file list available.

    -{% endif %} -- cgit v1.2.2 From 21c2d1a0de5fcc4f051179b9d0886105ab9d8cb0 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 18 Jan 2017 22:53:40 +0100 Subject: Remove unused jinja2.py --- packages/templatetags/jinja2.py | 71 ----------------------------------------- 1 file changed, 71 deletions(-) delete mode 100644 packages/templatetags/jinja2.py diff --git a/packages/templatetags/jinja2.py b/packages/templatetags/jinja2.py deleted file mode 100644 index 88b59a96..00000000 --- a/packages/templatetags/jinja2.py +++ /dev/null @@ -1,71 +0,0 @@ -from urllib import urlencode, quote as urlquote, unquote -from django.utils.html import escape -from django_jinja import library -from main.templatetags import pgp - - -@library.filter -def url_unquote(original_url): - try: - url = original_url - if isinstance(url, unicode): - url = url.encode('ascii') - url = unquote(url).decode('utf-8') - return url - except UnicodeError: - return original_url - - -def link_encode(url, query): - # massage the data into all utf-8 encoded strings first, so urlencode - # doesn't barf at the data we pass it - query = {k: unicode(v).encode('utf-8') for k, v in query.items()} - data = urlencode(query) - return "%s?%s" % (url, data) - - -@library.global_function -def pgp_key_link(key_id, link_text=None): - return pgp.pgp_key_link(key_id, link_text) - - -@library.global_function -def scm_link(package, operation): - parts = (package.repo.svn_root, operation, package.pkgbase) - linkbase = ( - "https://projects.archlinux.org/svntogit/%s.git/%s/trunk?" - "h=packages/%s") - return linkbase % tuple(urlquote(part.encode('utf-8')) for part in parts) - - -@library.global_function -def wiki_link(package): - url = "https://wiki.archlinux.org/index.php/Special:Search" - data = { - 'search': package.pkgname, - } - return link_encode(url, data) - - -@library.global_function -def bugs_list(package): - url = "https://bugs.archlinux.org/" - data = { - 'project': package.repo.bugs_project, - 'cat[]': package.repo.bugs_category, - 'string': package.pkgname, - } - return link_encode(url, data) - - -@library.global_function -def bug_report(package): - url = "https://bugs.archlinux.org/newtask" - data = { - 'project': package.repo.bugs_project, - 'product_category': package.repo.bugs_category, - 'item_summary': '[%s] PLEASE ENTER SUMMARY' % package.pkgname, - } - return link_encode(url, data) - -# vim: set ts=4 sw=4 et: -- cgit v1.2.2 From b4b625284ffedb5028fa63ca0a259bdabb852732 Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 13 Feb 2017 21:55:18 +0100 Subject: mirrors: rename .jinja to html --- templates/mirrors/url_details.html | 2 +- templates/mirrors/url_details_logs.html | 28 +++++++++++++++++++++++++++ templates/mirrors/url_details_logs.html.jinja | 28 --------------------------- 3 files changed, 29 insertions(+), 29 deletions(-) create mode 100644 templates/mirrors/url_details_logs.html delete mode 100644 templates/mirrors/url_details_logs.html.jinja diff --git a/templates/mirrors/url_details.html b/templates/mirrors/url_details.html index b61033cd..2454eda4 100644 --- a/templates/mirrors/url_details.html +++ b/templates/mirrors/url_details.html @@ -57,7 +57,7 @@

    Check Logs

    - {% include "mirrors/url_details_logs.html.jinja" %} + {% include "mirrors/url_details_logs.html" %} {% endblock %} diff --git a/templates/mirrors/url_details_logs.html b/templates/mirrors/url_details_logs.html new file mode 100644 index 00000000..a87e58d4 --- /dev/null +++ b/templates/mirrors/url_details_logs.html @@ -0,0 +1,28 @@ +{% load flags %} + + + + + + + + + + + + + + + + {% for log in logs %} + + + + + + + + + {% endfor %} + +
    Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
    {{ log.check_time|date:'Y-m-d H:i' }}{% if log.location %}{% country_flag log.location.country %}{{ log.location.country.name }}{% else %}Unknown{% endif %}{% if log.location %}{{ log.location.source_ip }}{% else %}Unknown{% endif %}{{ log.last_sync|date:'Y-m-d H:i' }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
    diff --git a/templates/mirrors/url_details_logs.html.jinja b/templates/mirrors/url_details_logs.html.jinja deleted file mode 100644 index a87e58d4..00000000 --- a/templates/mirrors/url_details_logs.html.jinja +++ /dev/null @@ -1,28 +0,0 @@ -{% load flags %} - - - - - - - - - - - - - - - - {% for log in logs %} - - - - - - - - - {% endfor %} - -
    Check TimeCheck LocationCheck IPLast SyncDelay (hh:mm)Duration (s)Success?Error Message
    {{ log.check_time|date:'Y-m-d H:i' }}{% if log.location %}{% country_flag log.location.country %}{{ log.location.country.name }}{% else %}Unknown{% endif %}{% if log.location %}{{ log.location.source_ip }}{% else %}Unknown{% endif %}{{ log.last_sync|date:'Y-m-d H:i' }}{{ log.delay|duration }}{{ log.duration|floatvalue }}{{ log.is_success|yesno|capfirst }}{{ log.error|linebreaksbr }}
    -- cgit v1.2.2 From c4dd0ead1557ff249b57c06c082516104e62062e Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 13 Feb 2017 22:06:14 +0100 Subject: Remove deprecated TEMPLATE_DEBUG --- local_settings.py.example | 1 - settings.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/local_settings.py.example b/local_settings.py.example index ffd6d8a6..d5c20063 100644 --- a/local_settings.py.example +++ b/local_settings.py.example @@ -1,6 +1,5 @@ ## Debug settings DEBUG = False -TEMPLATE_DEBUG = False #DEBUG_TOOLBAR = True ## For django debug toolbar diff --git a/settings.py b/settings.py index 7f28ec5c..2d36d063 100644 --- a/settings.py +++ b/settings.py @@ -3,7 +3,6 @@ import os ## Set the debug values DEBUG = False -TEMPLATE_DEBUG = DEBUG DEBUG_TOOLBAR = False ## Notification admins @@ -64,6 +63,7 @@ TEMPLATES = [ ], 'APP_DIRS': True, 'OPTIONS': { + 'debug': DEBUG, 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.core.context_processors.debug', -- cgit v1.2.2 From 353f803c4d0be7f4803873cd76359115303a4bca Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Mon, 13 Feb 2017 22:12:30 +0100 Subject: Remove the last piece of django-jinja existance --- mirrors/templatetags/jinja2.py | 53 ------------------------------------------ requirements.txt | 2 -- requirements_prod.txt | 2 -- settings.py | 11 --------- 4 files changed, 68 deletions(-) delete mode 100644 mirrors/templatetags/jinja2.py diff --git a/mirrors/templatetags/jinja2.py b/mirrors/templatetags/jinja2.py deleted file mode 100644 index 04e50238..00000000 --- a/mirrors/templatetags/jinja2.py +++ /dev/null @@ -1,53 +0,0 @@ -from datetime import timedelta -from django_jinja import library -from markupsafe import Markup - - -@library.global_function -def country_flag(country): - if not country: - return '' - html = ' ' % ( - unicode(country.code).lower(), unicode(country.name)) - return Markup(html) - - -@library.filter -def duration(value): - if not value and type(value) != timedelta: - return u'' - # does not take microseconds into account - total_secs = value.seconds + value.days * 24 * 3600 - mins = total_secs // 60 - hrs, mins = divmod(mins, 60) - return '%d:%02d' % (hrs, mins) - - -@library.filter -def hours(value): - if not value and type(value) != timedelta: - return u'' - # does not take microseconds into account - total_secs = value.seconds + value.days * 24 * 3600 - mins = total_secs // 60 - hrs, mins = divmod(mins, 60) - if hrs == 1: - return '%d hour' % hrs - return '%d hours' % hrs - - -@library.filter -def floatvalue(value, arg=2): - if value is None: - return u'' - return '%.*f' % (arg, value) - - -@library.filter -def percentage(value, arg=1): - if not value and type(value) != float: - return u'' - new_val = value * 100.0 - return '%.*f%%' % (arg, new_val) - -# vim: set ts=4 sw=4 et: diff --git a/requirements.txt b/requirements.txt index 864fac3a..a807da1f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,12 +1,10 @@ -e git+git://github.com/fredj/cssmin.git@master#egg=cssmin Django==1.8.18 IPy==0.83 -Jinja2==2.8 Markdown==2.6.2 MarkupSafe==0.23 bencode==1.0 django-countries==3.3 -django-jinja==2.2.0 jsmin==2.1.1 pgpdump==1.5 pytz>=2015.4 diff --git a/requirements_prod.txt b/requirements_prod.txt index bcb30f3e..7d311e3e 100644 --- a/requirements_prod.txt +++ b/requirements_prod.txt @@ -1,12 +1,10 @@ -e git+git://github.com/fredj/cssmin.git@master#egg=cssmin Django==1.7.8 IPy==0.83 -Jinja2==2.7.3 Markdown==2.6.2 MarkupSafe==0.23 bencode==1.0 django-countries==3.3 -django-jinja==1.3.3 jsmin==2.1.1 pgpdump==1.5 psycopg2==2.6.1 diff --git a/settings.py b/settings.py index 2d36d063..4a0ca9d2 100644 --- a/settings.py +++ b/settings.py @@ -46,16 +46,6 @@ AUTH_PROFILE_MODULE = 'devel.UserProfile' from os import path TEMPLATES = [ - { - 'BACKEND': 'django_jinja.backend.Jinja2', - 'APP_DIRS': True, - 'DIRS': [ - path.join(DEPLOY_PATH, 'templates/jinja') - ], - 'OPTIONS': { - 'match_extension': '.jinja' - } - }, { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ @@ -124,7 +114,6 @@ INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.staticfiles', 'django_countries', - 'django_jinja', 'main', 'mirrors', -- cgit v1.2.2 From 457f14f1cef3c7ed50d2bf2dcaf10cfce7da63dc Mon Sep 17 00:00:00 2001 From: Jelle van der Waa Date: Wed, 15 Feb 2017 19:30:41 +0100 Subject: templates: fix extranous comma in listings --- templates/packages/details_depend.html | 2 +- templates/packages/details_relatedto.html | 2 +- templates/packages/package_details.html | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/templates/packages/details_depend.html b/templates/packages/details_depend.html index 5e27374b..f471bc66 100644 --- a/templates/packages/details_depend.html +++ b/templates/packages/details_depend.html @@ -1,5 +1,5 @@ {% load details_link %}
  • {% if depend.pkg == None %} -{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} ({% for pkg in depend.providers %}{% details_link pkg %}{% if not loop.last %}, {% endif %}{% endfor %}) +{% if depend.providers %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} ({% for pkg in depend.providers %}{% details_link pkg %}{% if not forloop.last %}, {% endif %}{% endfor %}) {% else %}{{ depend.dep.name }}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} (virtual) {% endif %}{% else %} {% details_link depend.pkg %}{{ depend.dep.comparison|default:"" }}{{ depend.dep.version|default:"" }} diff --git a/templates/packages/details_relatedto.html b/templates/packages/details_relatedto.html index c22dfb7f..560a67f8 100644 --- a/templates/packages/details_relatedto.html +++ b/templates/packages/details_relatedto.html @@ -1,3 +1,3 @@ {% load details_link %}{% for related in all_related %}{% with best_satisfier=related.get_best_satisfier %} -{% if best_satisfier == None %}{{ related.name }}{% else %}{% details_link best_satisfier %}{% endif %}{{ related.comparison|default:'' }}{{ related.version|default:'' }}{% if not loop.last %}, {% endif %} +{% if best_satisfier == None %}{{ related.name }}{% else %}{% details_link best_satisfier %}{% endif %}{{ related.comparison|default:'' }}{{ related.version|default:'' }}{% if not forloop.last %}, {% endif %} {% endwith %}{% endfor %} diff --git a/templates/packages/package_details.html b/templates/packages/package_details.html index c0a066f2..d7c142e1 100644 --- a/templates/packages/package_details.html +++ b/templates/packages/package_details.html @@ -87,7 +87,7 @@ {% with splits=pkg.split_packages %}{% if splits %} Split Packages: - {% for s in splits %}{% details_link s %}{% if not loop.last %}, {% endif %}{% endfor %} + {% for s in splits %}{% details_link s %}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}{% endwith %} {% else %} @@ -117,7 +117,7 @@ Groups: {% for g in groups %} {{ g.name }}{% if not loop.last %}, {% endif %}{% endfor %} + title="Group details for {{ g.name }}">{{ g.name }}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}{% endwith %} @@ -143,7 +143,7 @@ Reverse Conflicts: {% for conflict in rev_conflicts %} - {% details_link conflict %}{% if not loop.last %}, {% endif %}{% endfor %} + {% details_link conflict %}{% if not forloop.last %}, {% endif %}{% endfor %} {% endif %}{% endwith %} -- cgit v1.2.2 From 49694232e2277212769bb5b174362dcf69db3408 Mon Sep 17 00:00:00 2001 From: Angel Velasquez Date: Wed, 17 May 2017 23:02:18 -0400 Subject: Fix reporead_inotify command It was broken since the migration to Django 1.8, also some pep8 modifications were done in order to improve the code quality --- devel/management/commands/reporead_inotify.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/devel/management/commands/reporead_inotify.py b/devel/management/commands/reporead_inotify.py index 1422ae26..fadcb881 100644 --- a/devel/management/commands/reporead_inotify.py +++ b/devel/management/commands/reporead_inotify.py @@ -35,6 +35,7 @@ logging.basicConfig( stream=sys.stderr) logger = logging.getLogger() + class Command(BaseCommand): help = "Watch database files and run an update when necessary." args = "[path_template]" @@ -73,16 +74,16 @@ class Command(BaseCommand): directories we need to watch for database updates. It then validates and passes these on to the various pyinotify pieces as necessary and finally builds and returns a notifier object.''' - transaction.commit_manually() - arches = Arch.objects.filter(agnostic=False) - repos = Repo.objects.all() - transaction.set_dirty() + with transaction.atomic(): + arches = Arch.objects.filter(agnostic=False) + repos = Repo.objects.all() + arch_path_map = {arch: None for arch in arches} all_paths = set() total_paths = 0 for arch in arches: - combos = ({ 'repo': repo.name.lower(), 'arch': arch.name } - for repo in repos) + combos = ({'repo': repo.name.lower(), 'arch': arch.name} + for repo in repos) # take a python format string and generate all unique combinations # of directories from it; using set() ensures we filter it down paths = {self.path_template % values for values in combos} @@ -97,7 +98,7 @@ class Command(BaseCommand): # template mapped to only one architecture if total_paths != len(all_paths): raise CommandError('path template did not uniquely ' - 'determine architecture for each file') + 'determine architecture for each file') # A proper atomic replacement of the database as done by rsync is type # IN_MOVED_TO. repo-add/remove will finish with a IN_CLOSE_WRITE. @@ -131,7 +132,7 @@ class Database(object): def _start_update_countdown(self): self.update_thread = threading.Timer(self.delay, self.update) logger.info('Starting %.1f second countdown to update %s', - self.delay, self.path) + self.delay, self.path) self.update_thread.start() def queue_for_update(self, mtime): -- cgit v1.2.2 From a9dcbbd1aa69e06e8373a7f0836fbc8a12d54b86 Mon Sep 17 00:00:00 2001 From: Angel Velasquez Date: Wed, 17 May 2017 23:11:44 -0400 Subject: Update news e-mail template Add missing quotes on the body. --- news/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/news/views.py b/news/views.py index b5bb4801..f85db171 100644 --- a/news/views.py +++ b/news/views.py @@ -46,7 +46,7 @@ class NewsCreateView(CreateView): template = loader.get_template('news/news_email_notification.txt') send_mail('[arch-announce] %s' % newsitem.title, template.render(ctx), - 'Arch Linux: Recent news updates: %s ' % newsitem.author.get_full_name(), + '"Arch Linux: Recent news updates: %s" ' % newsitem.author.get_full_name(), ['arch-announce@archlinux.org'], fail_silently=True) return super(NewsCreateView, self).form_valid(form) -- cgit v1.2.2