mirror of
https://git.linux-kernel.at/oliver/ivatar.git
synced 2025-11-17 13:38:03 +00:00
Pull in latest devel
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
[run]
|
||||
plugins =
|
||||
django_coverage_plugin
|
||||
omit =
|
||||
node_modules/*
|
||||
.virtualenv/*
|
||||
import_libravatar.py
|
||||
|
||||
[html]
|
||||
extra_css = coverage_extra_style.css
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -11,3 +11,4 @@ htmlcov/
|
||||
.ropeproject/
|
||||
db.sqlite3.SAVE
|
||||
node_modules/
|
||||
config_local.py
|
||||
|
||||
@@ -16,6 +16,9 @@ before_script:
|
||||
test_and_coverage:
|
||||
stage: test
|
||||
script:
|
||||
- echo 'from ivatar.settings import TEMPLATES' > config_local.py
|
||||
- echo 'TEMPLATES[0]["OPTIONS"]["debug"] = True' >> config_local.py
|
||||
- echo "DEBUG = True" >> config_local.py
|
||||
- python manage.py collectstatic --noinput
|
||||
- coverage run --source . manage.py test -v3
|
||||
- coverage report --fail-under=70
|
||||
|
||||
@@ -49,16 +49,14 @@ TEMPLATES[0]['OPTIONS']['context_processors'].append(
|
||||
OPENID_CREATE_USERS = True
|
||||
OPENID_UPDATE_DETAILS_FROM_SREG = True
|
||||
|
||||
SITE_NAME = os.environ.get('SITE_NAME', 'ivatar')
|
||||
IVATAR_VERSION = '0.1'
|
||||
SITE_NAME = os.environ.get('SITE_NAME', 'libravatar')
|
||||
IVATAR_VERSION = '1.0'
|
||||
|
||||
SECURE_BASE_URL = os.environ.get('SECURE_BASE_URL', 'https://avatars.linux-kernel.at/avatar/')
|
||||
BASE_URL = os.environ.get('BASE_URL', 'http://avatars.linux-kernel.at/avatar/')
|
||||
|
||||
LOGIN_REDIRECT_URL = reverse_lazy('profile')
|
||||
MAX_LENGTH_EMAIL = 254 # http://stackoverflow.com/questions/386294
|
||||
SERVER_EMAIL = 'accounts@mg.linux-kernel.at'
|
||||
DEFAULT_FROM_EMAIL = SERVER_EMAIL
|
||||
|
||||
MAX_NUM_PHOTOS = 5
|
||||
MAX_NUM_UNCONFIRMED_EMAILS = 5
|
||||
@@ -97,7 +95,7 @@ BOOTSTRAP4 = {
|
||||
}
|
||||
|
||||
if 'EMAIL_BACKEND' in os.environ:
|
||||
EMAIL_BACKEND = os.environ['EMAIL_BACKEND']
|
||||
EMAIL_BACKEND = os.environ['EMAIL_BACKEND'] # pragma: no cover
|
||||
else:
|
||||
if 'test' in sys.argv or 'collectstatic' in sys.argv:
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend'
|
||||
@@ -108,6 +106,7 @@ else:
|
||||
}
|
||||
EMAIL_BACKEND = 'anymail.backends.mailgun.EmailBackend' # pragma: no cover
|
||||
|
||||
SERVER_EMAIL = os.environ.get('SERVER_EMAIL', 'ivatar@mg.linux-kernel.at')
|
||||
DEFAULT_FROM_EMAIL = os.environ.get('DEFAULT_FROM_EMAIL', 'ivatar@mg.linux-kernel.at')
|
||||
|
||||
try:
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
'''
|
||||
Local config
|
||||
'''
|
||||
|
||||
from ivatar.settings import TEMPLATES # noqa
|
||||
|
||||
SESSION_COOKIE_SECURE = False
|
||||
DEBUG = True
|
||||
TEMPLATES[0]['OPTIONS']['debug'] = True
|
||||
@@ -31,7 +31,7 @@ from libravatar import libravatar_url
|
||||
from ivatar.settings import MAX_LENGTH_EMAIL, logger
|
||||
from ivatar.settings import MAX_PIXELS, AVATAR_MAX_SIZE, JPEG_QUALITY
|
||||
from ivatar.settings import MAX_LENGTH_URL
|
||||
from ivatar.settings import SECURE_BASE_URL, SITE_NAME, SERVER_EMAIL
|
||||
from ivatar.settings import SECURE_BASE_URL, SITE_NAME, DEFAULT_FROM_EMAIL
|
||||
from .gravatar import get_photo as get_gravatar_photo
|
||||
|
||||
|
||||
@@ -383,7 +383,7 @@ class UnconfirmedEmail(BaseAccountModel):
|
||||
# if settings.DEBUG:
|
||||
# print('DEBUG: %s' % link)
|
||||
send_mail(
|
||||
email_subject, email_body, SERVER_EMAIL,
|
||||
email_subject, email_body, DEFAULT_FROM_EMAIL,
|
||||
[self.email])
|
||||
return True
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ class RemoveUnconfirmedEmailView(SuccessMessageMixin, View):
|
||||
return HttpResponseRedirect(reverse_lazy('profile'))
|
||||
|
||||
|
||||
@method_decorator(login_required, name='dispatch')
|
||||
class ConfirmEmailView(SuccessMessageMixin, TemplateView):
|
||||
'''
|
||||
View class for confirming an unconfirmed email address
|
||||
|
||||
80
ivatar/test_static_pages.py
Normal file
80
ivatar/test_static_pages.py
Normal file
@@ -0,0 +1,80 @@
|
||||
'''
|
||||
Test our views in ivatar.ivataraccount.views and ivatar.views
|
||||
'''
|
||||
# pylint: disable=too-many-lines
|
||||
from urllib.parse import urlsplit
|
||||
from io import BytesIO
|
||||
import io
|
||||
import os
|
||||
import django
|
||||
from django.test import TestCase
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import authenticate
|
||||
import hashlib
|
||||
|
||||
from libravatar import libravatar_url
|
||||
|
||||
from PIL import Image
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings'
|
||||
django.setup()
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
from ivatar import settings
|
||||
from ivatar.ivataraccount.forms import MAX_NUM_UNCONFIRMED_EMAILS_DEFAULT
|
||||
from ivatar.ivataraccount.models import Photo, ConfirmedOpenId
|
||||
from ivatar.utils import random_string
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
class Tester(TestCase): # pylint: disable=too-many-public-methods
|
||||
'''
|
||||
Main test class
|
||||
'''
|
||||
client = Client()
|
||||
user = None
|
||||
username = random_string()
|
||||
password = random_string()
|
||||
email = '%s@%s.%s' % (username, random_string(), random_string(2))
|
||||
# Dunno why random tld doesn't work, but I'm too lazy now to investigate
|
||||
openid = 'http://%s.%s.%s/' % (username, random_string(), 'org')
|
||||
|
||||
def login(self):
|
||||
'''
|
||||
Login as user
|
||||
'''
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
Prepare for tests.
|
||||
- Create user
|
||||
'''
|
||||
self.user = User.objects.create_user(
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
)
|
||||
|
||||
def test_contact_page(self):
|
||||
"""
|
||||
Test contact page
|
||||
"""
|
||||
response = self.client.get(reverse('contact'))
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
|
||||
def test_description_page(self):
|
||||
"""
|
||||
Test description page
|
||||
"""
|
||||
response = self.client.get(reverse('description'))
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
|
||||
def test_security_page(self):
|
||||
"""
|
||||
Test security page
|
||||
"""
|
||||
response = self.client.get(reverse('security'))
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
|
||||
65
ivatar/test_views.py
Normal file
65
ivatar/test_views.py
Normal file
@@ -0,0 +1,65 @@
|
||||
'''
|
||||
Test our views in ivatar.ivataraccount.views and ivatar.views
|
||||
'''
|
||||
# pylint: disable=too-many-lines
|
||||
from urllib.parse import urlsplit
|
||||
from io import BytesIO
|
||||
import io
|
||||
import os
|
||||
import django
|
||||
from django.test import TestCase
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import authenticate
|
||||
import hashlib
|
||||
|
||||
from libravatar import libravatar_url
|
||||
|
||||
from PIL import Image
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings'
|
||||
django.setup()
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
from ivatar import settings
|
||||
from ivatar.ivataraccount.forms import MAX_NUM_UNCONFIRMED_EMAILS_DEFAULT
|
||||
from ivatar.ivataraccount.models import Photo, ConfirmedOpenId
|
||||
from ivatar.utils import random_string
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
class Tester(TestCase): # pylint: disable=too-many-public-methods
|
||||
'''
|
||||
Main test class
|
||||
'''
|
||||
client = Client()
|
||||
user = None
|
||||
username = random_string()
|
||||
password = random_string()
|
||||
email = '%s@%s.%s' % (username, random_string(), random_string(2))
|
||||
# Dunno why random tld doesn't work, but I'm too lazy now to investigate
|
||||
openid = 'http://%s.%s.%s/' % (username, random_string(), 'org')
|
||||
|
||||
def login(self):
|
||||
'''
|
||||
Login as user
|
||||
'''
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
Prepare for tests.
|
||||
- Create user
|
||||
'''
|
||||
self.user = User.objects.create_user(
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
)
|
||||
|
||||
def test_incorrect_digest(self):
|
||||
"""
|
||||
Test incorrect digest
|
||||
"""
|
||||
response = self.client.get('/avatar/%s' % 'x'*65)
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
28
ivatar/tools/templates/check_domain.html
Normal file
28
ivatar/tools/templates/check_domain.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}{% trans 'Check e-mail or openid' %}{% endblock title %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<h1>{% trans 'Check domain' %}</h1>
|
||||
|
||||
<div style="max-width:640px">
|
||||
<form method="post" name="check">
|
||||
{% csrf_token %}
|
||||
<div class="form-group"><label for="id_mail">{% trans 'Domain' %}</label>
|
||||
<input type="domain" name="domain" maxlength="254" minlength="6" class="form-control" placeholder="{% trans 'Domain' %}" {% if form.domain.value %} value="{{ form.domain.value }}" {% endif %} id="id_domain"></div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="btn btn-default">{% trans 'Check' %}</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if result %}
|
||||
<hr/>
|
||||
<h2>Domain check - TODO TODO</h2>
|
||||
<p/>
|
||||
{% endif %}
|
||||
<div style="height:40px"></div>
|
||||
{% endblock content %}
|
||||
72
ivatar/tools/test_views.py
Normal file
72
ivatar/tools/test_views.py
Normal file
@@ -0,0 +1,72 @@
|
||||
'''
|
||||
Test our views in ivatar.ivataraccount.views and ivatar.views
|
||||
'''
|
||||
# pylint: disable=too-many-lines
|
||||
from urllib.parse import urlsplit
|
||||
from io import BytesIO
|
||||
import io
|
||||
import os
|
||||
import django
|
||||
from django.test import TestCase
|
||||
from django.test import Client
|
||||
from django.urls import reverse
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.auth import authenticate
|
||||
import hashlib
|
||||
|
||||
from libravatar import libravatar_url
|
||||
|
||||
from PIL import Image
|
||||
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = 'ivatar.settings'
|
||||
django.setup()
|
||||
|
||||
# pylint: disable=wrong-import-position
|
||||
from ivatar import settings
|
||||
from ivatar.ivataraccount.forms import MAX_NUM_UNCONFIRMED_EMAILS_DEFAULT
|
||||
from ivatar.ivataraccount.models import Photo, ConfirmedOpenId
|
||||
from ivatar.utils import random_string
|
||||
# pylint: enable=wrong-import-position
|
||||
|
||||
|
||||
class Tester(TestCase): # pylint: disable=too-many-public-methods
|
||||
'''
|
||||
Main test class
|
||||
'''
|
||||
client = Client()
|
||||
user = None
|
||||
username = random_string()
|
||||
password = random_string()
|
||||
email = '%s@%s.%s' % (username, random_string(), random_string(2))
|
||||
# Dunno why random tld doesn't work, but I'm too lazy now to investigate
|
||||
openid = 'http://%s.%s.%s/' % (username, random_string(), 'org')
|
||||
|
||||
def login(self):
|
||||
'''
|
||||
Login as user
|
||||
'''
|
||||
self.client.login(username=self.username, password=self.password)
|
||||
|
||||
def setUp(self):
|
||||
'''
|
||||
Prepare for tests.
|
||||
- Create user
|
||||
'''
|
||||
self.user = User.objects.create_user(
|
||||
username=self.username,
|
||||
password=self.password,
|
||||
)
|
||||
|
||||
def test_check(self):
|
||||
"""
|
||||
Test check page
|
||||
"""
|
||||
response = self.client.get(reverse('tools_check'))
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
|
||||
def test_check_domain(self):
|
||||
"""
|
||||
Test check domain page
|
||||
"""
|
||||
response = self.client.get(reverse('tools_check_domain'))
|
||||
self.assertEqual(response.status_code, 200, 'no 200 ok?')
|
||||
@@ -69,8 +69,8 @@ class CheckView(FormView):
|
||||
mail_hash256 = hash_obj.hexdigest()
|
||||
size = form.cleaned_data['size']
|
||||
if form.cleaned_data['openid']:
|
||||
if form.cleaned_data['openid'][-1] != '/':
|
||||
form.cleaned_data['openid'] += '/'
|
||||
if not form.cleaned_data['openid'].startswith('http://') and not form.cleaned_data['openid'].startswith('https://'):
|
||||
form.cleaned_data['openid'] = 'http://%s' % form.cleaned_data['openid']
|
||||
openidurl = libravatar_url(
|
||||
openid=form.cleaned_data['openid'],
|
||||
size=form.cleaned_data['size'],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load static %}
|
||||
{% load i18n %}<!DOCTYPE HTML>
|
||||
{% include 'header.html' %}
|
||||
<title>iVatar :: {% block title %}{% trans 'Freeing the Web, one face at a time!' %}{% endblock title %}</title>
|
||||
<title>{{ site_name }} :: {% block title %}{% trans 'Freeing the Web, one face at a time!' %}{% endblock title %}</title>
|
||||
|
||||
{% spaceless %}
|
||||
<div id="page">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{% load static %}
|
||||
{% load i18n %}<!DOCTYPE HTML>
|
||||
{% include 'header.html' %}
|
||||
<title>iVatar :: {% block title %}{% trans 'Freeing the Web, one face at a time!' %}{% endblock title %}</title>
|
||||
<title>{{ site_name }} :: {% block title %}{% trans 'Freeing the Web, one face at a time!' %}{% endblock title %}</title>
|
||||
|
||||
{% spaceless %}
|
||||
<div id="page">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<footer>
|
||||
<div class="container">
|
||||
<div class="pull-left">
|
||||
<p><b>{% blocktrans %}{{ site_name }}</b> is an service running the <a href="https://launchpad.net/libravatar">ivatar</a> software, version {{ ivatar_version }} under the <a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPLv3.0</a> license.{% endblocktrans %}
|
||||
<p><b>{% blocktrans %}{{ site_name }}</b> is a service running the <a href="https://git.linux-kernel.at/oliver/ivatar/">ivatar</a> software, version {{ ivatar_version }} under the <a href="http://www.gnu.org/licenses/agpl-3.0.html">AGPLv3.0</a> license.{% endblocktrans %}
|
||||
{% block footer %}{% endblock footer %}</p>
|
||||
</div>
|
||||
<div class="pull-right">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<div class="hero">
|
||||
<div class="container">
|
||||
<header>
|
||||
<h1>{% trans 'ivatar' %}</h1>
|
||||
<h1>{{ site_name }}</h1>
|
||||
<h2>{% trans 'freeing the web one face at a time' %}</h2>
|
||||
{% if user.is_anonymous %}
|
||||
<a href="/accounts/login/" class="btn btn-lg btn-primary">{% trans 'Login' %}</a>
|
||||
@@ -47,14 +47,14 @@
|
||||
<div class="container">
|
||||
<div class="text-center">
|
||||
<h2>{% trans 'The open avatar service' %}</h2>
|
||||
<p class="lead">{% blocktrans %}ivatar is a service which delivers your avatar (profile picture) to other websites. If you create an account with us, your photo could start popping up next to forum posts or blog comments on any site where you left your email address.{% endblocktrans %}<br>
|
||||
<p class="lead">{% blocktrans %}{{ site_name }} is a service which delivers your avatar (profile picture) to other websites. If you create an account with us, your photo could start popping up next to forum posts or blog comments on any site where you left your email address.{% endblocktrans %}<br>
|
||||
<a href="https://wiki.libravatar.org/description/">{% trans 'Read more...' %}</a></p>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="row">
|
||||
<section class="col-md-8">
|
||||
<h1>{% trans 'Federated Open Source Service' %}</h1>
|
||||
<p class="lead">{% trans 'This service is powered by <a href="https://www.gnu.org/licenses/agpl.html">Free and Open Source software</a> and allows owners of a domain name to <a href="https://wiki.libravatar.org/running_your_own/">run their own instance</a> of ivatar and serve avatars themselves.' %}</p>
|
||||
<p class="lead">{% trans 'This service is powered by <a href="https://www.gnu.org/licenses/agpl.html">Free and Open Source software</a> called <a href="https://git.linux-kernel.at/oliver/ivatar">ivatar</a>. With this software you can also <a href="https://wiki.libravatar.org/running_your_own/">run your own instance</a> and serve avatars yourself.' %}</p>
|
||||
<hr>
|
||||
<h1>{% trans 'Simple API for Developers' %}</h1>
|
||||
<p class="lead">{% trans 'Application developers can easily add support for this service using our <a href="https://wiki.libravatar.org/api/">simple API</a> or one of the <a href="https://wiki.libravatar.org/libraries/">libraries and plugins</a> available for a number of platforms and languages.' %}</p>
|
||||
|
||||
Reference in New Issue
Block a user