Skip to content

Commit

Permalink
Merge branch 'master' into oauth-login
Browse files Browse the repository at this point in the history
  • Loading branch information
stefankoegl committed Sep 2, 2018
2 parents 64e0e76 + 6a53bdd commit 9e32ac6
Show file tree
Hide file tree
Showing 192 changed files with 7,011 additions and 2,994 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
*.pyc
htdocs/media/logo/*
media/*
logs/*
*.mo
mygpo/settings_prod.py
Expand All @@ -23,3 +23,9 @@ venv*

# envdirs
envs

# Jupyter Notebooks
notebooks/

.cache
.pytest_cache
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: python

python:
- "3.5"
- "3.6"
- "3.6-dev"
- "3.7-dev"
Expand All @@ -19,7 +18,7 @@ before_script:
- psql -c 'create database mygpo_test;' -U postgres

script:
coverage run --branch --source=mygpo ./manage.py test
- pytest --cov=mygpo/ --cov-branch

after_script:
- coveralls
Expand All @@ -28,3 +27,11 @@ env:
- DATABASE_URL="postgres://postgres@localhost/mygpo_test"

sudo: false

# temporarily allow failures on 3.7
# see https://github.com/chtd/psycopg2cffi/issues/95
matrix:
allow_failures:
- python: "3.7-dev"
- python: "nightly"

5 changes: 3 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
web: gunicorn mygpo.wsgi:application -c gunicorn.conf.py
beat: python manage.py celery beat -S django --pidfile /var/run/mygpo/celerybeat.pid
web: gunicorn mygpo.wsgi:application -c conf/gunicorn.conf.py
beat: celery -A mygpo beat --pidfile /tmp/celerybeat.pid -S django
celery: celery -A mygpo worker --concurrency=3 -l info -Ofair
File renamed without changes.
9 changes: 9 additions & 0 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pytest


@pytest.fixture(autouse=True)
def enable_db_access_for_all_tests(db):
""" Enable DB access for all tests
http://pytest-django.readthedocs.io/en/latest/faq.html#how-can-i-give-database-access-to-all-my-tests-without-the-django-db-marker """
pass
2 changes: 1 addition & 1 deletion doc/api/reference/devices.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Update Device Data
List Devices
------------

.. http:post:: /api/2/devices/(username).json
.. http:get:: /api/2/devices/(username).json
:synopsis: list the user's devices

* Requires HTTP authentication
Expand Down
5 changes: 5 additions & 0 deletions doc/dev/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,8 @@ Social Login

* ``GOOGLE_CLIENT_ID`` - Google Client ID
* ``GOOGLE_CLIENT_SECRET`` - Google Client Secret


API
---
* ``MAX_EPISODE_ACTIONS`` - maximum number of episode actions that the API will return in one `GET` request.
3 changes: 2 additions & 1 deletion doc/dev/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ gpodder.net
The sourcecode of the webservice gpodder.net is released as open source under
the `AGPLv3 <http://www.gnu.org/licenses/agpl-3.0.html>`_ and `hosted at GitHub
<https://github.com/gpodder/mygpo>`_. Bugs can be reported at the `gPodder
Bugtracker <https://bugs.gpodder.org/enter_bug.cgi?product=gpodder.net>`_.
Bugtracker <https://github.com/gpodder/mygpo/issues>`_.

Integrating Clients
-------------------
Expand All @@ -30,3 +30,4 @@ Contents
postgres-setup
libraries
configuration
jupyter-notebook
67 changes: 40 additions & 27 deletions doc/dev/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,7 @@ Now install additional dependencies locally:
pip install -r requirements-test.txt # for running tests
That's it for the setup. Now to initialize the DB:

First run the commands from :ref:`db-setup`. Then

.. code-block:: bash
cd mygpo
python manage.py migrate
..and here we go:

.. code-block:: bash
python manage.py runserver
That's it for the setup.


Configuration
Expand All @@ -72,9 +59,35 @@ For a development configuration you will probably want to use the following
echo postgres://mygpo:mygpo@localhost/mygpo > envs/local/DATABASE_URL
echo True > envs/local/DEBUG
On an Debian/Ubuntu based system, you can perform this configuration with

.. code-block:: bash
make dev-config
See :ref:`configuration` for further information.


Database Initialization
-----------------------

Now to initialize the DB:

First run the commands from :ref:`db-setup`. Then

.. code-block:: bash
cd mygpo
envdir envs/local python manage.py migrate
..and here we go:

.. code-block:: bash
envdir envs/local python manage.py runserver
Accessing the dev server from other devices
-------------------------------------------

Expand All @@ -84,7 +97,7 @@ runserver command of manage.py, like this:

.. code-block:: bash
python manage.py runserver 0.0.0.0:8000
envdir envs/local python manage.py runserver 0.0.0.0:8000
Beware, though, that this will expose the web service to your all networks
that your machine is connected to. Apply common sense and ideally use only
Expand All @@ -101,22 +114,22 @@ commands regularly on your development machine:

.. code-block:: bash
python manage.py update-categories
python manage.py update-toplist
python manage.py update-episode-toplist
envdir envs/local python manage.py update-categories
envdir envs/local python manage.py update-toplist
envdir envs/local python manage.py update-episode-toplist
python manage.py feed-downloader
python manage.py feed-downloader <feed-url> [...]
python manage.py feed-downloader --max <max-updates>
python manage.py feed-downloader --random --max <max-updates>
python manage.py feed-downloader --toplist --max <max-updates>
python manage.py feed-downloader --update-new --max <max-updates>
envdir envs/local python manage.py feed-downloader
envdir envs/local python manage.py feed-downloader <feed-url> [...]
envdir envs/local python manage.py feed-downloader --max <max-updates>
envdir envs/local python manage.py feed-downloader --random --max <max-updates>
envdir envs/local python manage.py feed-downloader --toplist --max <max-updates>
envdir envs/local python manage.py feed-downloader --update-new --max <max-updates>
or to only do a dry run (this won't do any web requests for feeds):

.. code-block:: bash
python manage.py feed-downloader --list-only [other parameters]
envdir envs/local python manage.py feed-downloader --list-only [other parameters]
Maintaining publisher relationships with user accounts
Expand All @@ -127,7 +140,7 @@ To set a user as publisher for a given feed URL, use:
.. code-block:: bash
cd mygpo
python manage.py make-publisher <username> <feed-url> [...]
envdir envs/local python manage.py make-publisher <username> <feed-url> [...]
Web-Server
Expand All @@ -138,7 +151,7 @@ directory with

.. code-block:: bash
python manage.py runserver
envdir envs/local python manage.py runserver
If you want to run a production server, check out `Deploying Django
<https://docs.djangoproject.com/en/dev/howto/deployment/>`_.
28 changes: 28 additions & 0 deletions doc/dev/jupyter-notebook.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
.. _jupyter-notebook:

Jupyter Notebook
================

You can use `Jupyter Notebooks <http://jupyter.org/>`_ during development for
exploring data and prototyping methods.

To do so, follow these steps

* Make sure you have all requirements from ``requirements-dev.txt`` installed.

* Run ``make notebook``, which will start the notebook and open it in the
browser .

* Navigate to the directory ``notebooks`` (listed in `.gitignore`) and create
a new notebook.

* Use the following code in the first cell to setup your environment

.. code-block:: python
MYPROJECT = '/path/to/mygpo'
import os, sys
sys.path.insert(0, MYPROJECT)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "local_settings.py")
import django
django.setup()
Binary file removed htdocs/media/16x16/emblem-default.png
Binary file not shown.
Binary file removed htdocs/media/16x16/server.png
Binary file not shown.
Binary file removed htdocs/media/24x24/opml-icon.png
Binary file not shown.
Binary file removed htdocs/media/32x32/audio-x-generic.png
Binary file not shown.
Binary file removed htdocs/media/32x32/computer.png
Binary file not shown.
Binary file removed htdocs/media/32x32/server.png
Binary file not shown.
Binary file removed htdocs/media/FontAwesome.ttf
Binary file not shown.
Binary file removed htdocs/media/charts-new.png
Binary file not shown.
Binary file removed htdocs/media/dialog-error.png
Binary file not shown.
Binary file removed htdocs/media/emblem-default.png
Binary file not shown.
Binary file removed htdocs/media/img/glyphicons-halflings-white.png
Binary file not shown.
Binary file removed htdocs/media/img/glyphicons-halflings.png
Binary file not shown.
Binary file removed htdocs/media/info.png
Binary file not shown.
Binary file removed htdocs/media/mygpo18.png
Binary file not shown.
23 changes: 18 additions & 5 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,28 @@ help:
@echo 'make test run tests and show coverage report'
@echo 'make clean clean up files'

test:
envdir envs/dev/ python -Wd -m coverage run ./manage.py test
coverage report
dev-config:
mkdir -p envs/local
echo django.core.mail.backends.console.EmailBackend > envs/local/EMAIL_BACKEND
echo secret > envs/local/SECRET_KEY
echo postgres://mygpo:mygpo@localhost/mygpo > envs/local/DATABASE_URL
echo True > envs/local/DEBUG

test: envs/test/MEDIA_ROOT
# assume defined media root directory, empty before running tests
rm -rf $(shell cat envs/test/MEDIA_ROOT)
mkdir -p $(shell cat envs/test/MEDIA_ROOT)
envdir envs/dev/ pytest --cov=mygpo/ --cov-branch
coverage report --show-missing

update-po:
envdir envs/dev/ python manage.py makemessages \
--ignore=doc/* --ignore=envs/* --ignore=htdocs/* --ignore=venv/* \
--ignore=res/* --ignore=tools/* --ignore=mygpo/*/migrations/*
--ignore=doc/* --ignore=envs/* --ignore=media/* --ignore=venv/* \
--ignore=res/* --ignore=tools/* --ignore=mygpo/*/migrations/* \
--ignore=static/*

notebook:
envdir envs/dev/ python manage.py shell_plus --notebook

clean:
git clean -fX
Expand Down
10 changes: 10 additions & 0 deletions mygpo/administration/templates/admin/hostinfo.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends "base.html" %}
{% load i18n %}
{% load time %}
{% load podcasts %}

{% load menu %}
Expand Down Expand Up @@ -62,6 +63,15 @@ <h1>{% trans "Host Information" %}</h1>
<td class="numeric">{{ num_index_outdated }}</td>
</tr>

<tr>
<td>
<strong>
{% trans "Average podcast update duration" %}
</strong>
</td>
<td class="numeric">{{ avg_podcast_update_duration.total_seconds|format_duration}}</td>
</tr>

<tr>
<td><strong>{% trans "Scheduled Celery Tasks" %}</strong></td>
<td><tt>{{ num_celery_tasks }}</tt></td>
Expand Down
1 change: 1 addition & 0 deletions mygpo/administration/templates/admin/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ <h1>{% trans "Admin Area" %}</h1>
<li><i class="icon-bar-chart"></i> <a href="{% url "useragents" %}">{% trans "User-Agent Stats" %}</a></li>
<li><i class="icon-signal"></i> <a href="{% url "stats" %}">{% trans "General Stats" %}</a> (<a href="{% url "stats-json" %}">{% trans "JSON" %}</a>)</li>
<li><i class="icon-certificate"></i> <a href="{% url "admin-activate-user" %}">{% trans "Activate User" %}</a></li>
<li><i class="icon-certificate"></i> <a href="{% url "admin-resend-activation" %}">{% trans "Resend Activation Email" %}</a></li>
<li><i class="icon-user"></i> <a href="{% url "admin-make-publisher-input" %}">{% trans "Assign Publisher Permissions" %}</a></li>
</ul>

Expand Down
41 changes: 41 additions & 0 deletions mygpo/administration/templates/admin/resend-acivation.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{% extends "base.html" %}
{% load i18n %}
{% load podcasts %}

{% load menu %}
{% block mainmenu %}{{ "/admin/"|main_menu }}{% endblock %}
{% block sectionmenu %}{{ "/admin/"|section_menu:"Admin" }}{% endblock %}

{% block title %}{% trans "Activate User" %}{% endblock %}

{% block header %}
<h1>{% trans "Resend Activation email" %}</h1>
{% endblock %}

{% block content %}
<form class="form-horizontal" method="post" action="{% url "admin-resend-activation" %}">
{% csrf_token %}

<div class="control-group">
<label class="control-label" for="username">{% trans "Username" %}</label>
<div class="controls">
<input name="username" type="text" id="username" placeholder="Username">
</div>
</div>

<div class="control-group">
<label class="control-label" for="email">{% trans "Email" %}</label>
<div class="controls">
<input name="email" type="text" id="email" placeholder="Email">
</div>
</div>

<div class="control-group">
<div class="controls">
<button type="submit" class="btn">{% trans "Resend" %}</button>
</div>
</div>
</form>

{% endblock %}

12 changes: 6 additions & 6 deletions mygpo/administration/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ class SimpleTest(TestCase):

def test_merge(self):

p1 = Podcast.objects.get_or_create_for_url('http://example.com/podcast1.rss')
p2 = Podcast.objects.get_or_create_for_url('http://example.com/podcast2.rss')
p1 = Podcast.objects.get_or_create_for_url('http://example.com/podcast1.rss').object
p2 = Podcast.objects.get_or_create_for_url('http://example.com/podcast2.rss').object

e1 = Episode.objects.get_or_create_for_url(p1, 'http://example.com/podcast1/e1.mp3')
e1 = Episode.objects.get_or_create_for_url(p1, 'http://example.com/podcast1/e1.mp3').object
e1.title = 'Episode 1'
e1.save()

e2 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast1/e2.mp3')
e2 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast1/e2.mp3').object
e2.title = 'Episode 2'
e2.save()

e3 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast2/e2.mp3')
e3 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast2/e2.mp3').object
e3.title = 'Episode 3'
e3.save()

e4 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast2/e3.mp3')
e4 = Episode.objects.get_or_create_for_url(p2, 'http://example.com/podcast2/e3.mp3').object
e4.title = 'Episode 4'
e4.save()

Expand Down
Loading

0 comments on commit 9e32ac6

Please sign in to comment.