Skip to content

Commit

Permalink
more user and organisation app cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Sep 12, 2024
1 parent 3bca384 commit 1479b19
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 426 deletions.
37 changes: 0 additions & 37 deletions euth/users/adapters.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
import re
from urllib.parse import quote

from allauth.account.adapter import DefaultAccountAdapter
from django.utils.http import url_has_allowed_host_and_scheme

from adhocracy4.emails import Email
from adhocracy4.emails.mixins import SyncEmailMixin
from euth.users import USERNAME_REGEX


class EuthAccountEmail(SyncEmailMixin, Email):
def get_receivers(self):
return [self.object]

@property
def template_name(self):
return self.kwargs['template_name']


class EuthAccountAdapter(DefaultAccountAdapter):
username_regex = re.compile(USERNAME_REGEX)

Expand All @@ -31,27 +18,3 @@ def is_open_for_signup(self, request):
(Comment reproduced from the overridden method.)
"""
return False

def get_email_confirmation_url(self, request, emailconfirmation):
url = super().get_email_confirmation_url(request, emailconfirmation)
if 'next' in request.POST \
and url_has_allowed_host_and_scheme(request.POST['next'],
allowed_hosts=None):
return '{}?next={}'.format(url, quote(request.POST['next']))
else:
return url

def send_mail(self, template_prefix, email, context):
return EuthAccountEmail.send(
email,
template_name=template_prefix,
**context
)

def get_email_confirmation_redirect_url(self, request):
if 'next' in request.GET \
and url_has_allowed_host_and_scheme(request.GET['next'],
allowed_hosts=None):
return request.GET['next']
else:
return super().get_email_confirmation_redirect_url(request)
4 changes: 0 additions & 4 deletions euth/users/templates/euth_users/indicator_menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@
</li>
{% endif %}

<li>
<a href="{% url 'account-profile' %}" class="dropdown-item"><i class="fa fa-cog"></i><span class="dropdown-text">{% trans "Account Settings" %}</span></a>
</li>

<li class="p-0">
<form class="logout-button-form" action="{% url 'account_logout' %}" method="post" >
{% csrf_token %}
Expand Down
91 changes: 0 additions & 91 deletions euth/users/templates/euth_users/user_detail.html

This file was deleted.

1 change: 0 additions & 1 deletion euth/users/templates/euth_users/user_search.html

This file was deleted.

1 change: 0 additions & 1 deletion euth_wagtail/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
'widget_tweaks',
'easy_thumbnails',
'parler',
'background_task',

'django.contrib.sites',
'django.contrib.admin',
Expand Down
49 changes: 0 additions & 49 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,12 @@
import factory
import pytest
from django.urls import reverse
from pytest_factoryboy import register
from rest_framework.test import APIClient

from adhocracy4.test import factories as a4_factories
from adhocracy4.test import helpers
from tests.organisations import factories as org_factories

from . import factories

register(factories.UserFactory)
register(factories.UserFactory, 'user2')
register(factories.AdminFactory, 'admin')
register(factories.ContentTypeFactory)

register(org_factories.OrganisationFactory)
register(org_factories.OrganisationFactory, 'other_organisation')
register(a4_factories.GroupFactory)
register(a4_factories.ProjectFactory)
register(a4_factories.ModuleFactory)
register(factories.PhaseFactory)


def pytest_configure(config):
# Patch email background_task decorators for all tests
helpers.patch_background_task_decorator('adhocracy4.emails.tasks')


@pytest.fixture
def apiclient():
return APIClient()


@pytest.fixture
def smallImage():
return factory.django.ImageField(width=200, height=200)


@pytest.fixture
def bigImage():
return factory.django.ImageField(width=1400, height=1400)


@pytest.fixture
def ImageBMP():
return factory.django.ImageField(width=1400, height=1400, format='BMP')


@pytest.fixture
def ImagePNG():
return factory.django.ImageField(width=1400, height=1400, format='PNG')


@pytest.fixture
def image_factory():
return factories.ImageFactory()


@pytest.fixture
Expand Down
23 changes: 0 additions & 23 deletions tests/contrib/test_middleware.py

This file was deleted.

38 changes: 0 additions & 38 deletions tests/factories.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
from io import BytesIO

import factory
from django.conf import settings
from django.contrib.auth.hashers import make_password
from django.core.files import base
from django.core.files import images
from PIL import Image

from adhocracy4.test import factories


class UserFactory(factory.django.DjangoModelFactory):
Expand All @@ -18,39 +11,8 @@ class Meta:
username = factory.Sequence(lambda n: 'user{}'.format(n))
password = make_password('password')
email = factory.Sequence(lambda n: 'user{}@liqd.net'.format(n))
timezone = factory.Faker('timezone')


class AdminFactory(UserFactory):
is_superuser = True
is_staff = True


class ContentTypeFactory(factory.django.DjangoModelFactory):

class Meta:
model = 'contenttypes.ContentType'

app_label = factory.Faker('name')
model = factory.Faker('name')
name = factory.Faker('name')


class PhaseFactory(factories.PhaseFactory):
type = 'blog:phase'


class ImageFactory():
"""
Create a django file object containg an image.
"""

def __call__(self, resolution, image_format='JPEG', name=None):

filename = name or 'default.{}'.format(image_format.lower())
color = 'blue'
image = Image.new('RGB', resolution, color)
image_data = BytesIO()
image.save(image_data, image_format)
image_content = base.ContentFile(image_data.getvalue())
return images.ImageFile(image_content.file, filename)
Empty file removed tests/organisations/__init__.py
Empty file.
28 changes: 0 additions & 28 deletions tests/organisations/factories.py

This file was deleted.

Loading

0 comments on commit 1479b19

Please sign in to comment.