mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2026-02-04 14:16:21 +01:00
Compare commits
191 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
635fbfe2c8 | ||
|
|
b10233daf0 | ||
|
|
1aa3187491 | ||
|
|
59f17a88f0 | ||
|
|
1072c00a28 | ||
|
|
b221c1ce24 | ||
|
|
1617c775ee | ||
|
|
cc88a02001 | ||
|
|
ae5d0f4a2f | ||
|
|
067e2c424e | ||
|
|
d64675a3b0 | ||
|
|
17a6b3225e | ||
|
|
b83f591dc2 | ||
|
|
be2fbe862b | ||
|
|
f95bee0921 | ||
|
|
2f9ae8b054 | ||
|
|
74651dd30a | ||
|
|
9cdcd8365c | ||
|
|
f5d70a2c48 | ||
|
|
f40ebbfba4 | ||
|
|
2551a9dd64 | ||
|
|
e3b01ccbc9 | ||
|
|
267a392945 | ||
|
|
634d021bf2 | ||
|
|
4e8bfba738 | ||
|
|
297f98f046 | ||
|
|
27dad05927 | ||
|
|
697e9dd772 | ||
|
|
312951ea3f | ||
|
|
e4bf96cfb6 | ||
|
|
3bd6baa8f9 | ||
|
|
06e38dcd93 | ||
|
|
f47b9eee5b | ||
|
|
0d4cab66b2 | ||
|
|
dc23ee8ad2 | ||
|
|
65f2efc890 | ||
|
|
def30900b4 | ||
|
|
d7fabccddd | ||
|
|
45289e1d17 | ||
|
|
e7bafaa4d8 | ||
|
|
ba3f1507be | ||
|
|
7b9bf08aa3 | ||
|
|
360458f574 | ||
|
|
def6431052 | ||
|
|
a47bd8d7c7 | ||
|
|
22a270aedb | ||
|
|
54bce4315b | ||
|
|
c930f7bbeb | ||
|
|
8c1f06d7b8 | ||
|
|
815b6fa030 | ||
|
|
7c05217900 | ||
|
|
64ee273953 | ||
|
|
d8c2944966 | ||
|
|
7669c9e55d | ||
|
|
71c9faaf28 | ||
|
|
236c70316c | ||
|
|
0d0686f58a | ||
|
|
3706a1aedf | ||
|
|
47f1b77320 | ||
|
|
8dec242a93 | ||
|
|
6b934060dd | ||
|
|
ff88a16163 | ||
|
|
e81a66b74b | ||
|
|
2ff200c566 | ||
|
|
091a2637ea | ||
|
|
6c7729308c | ||
|
|
0195ef23d5 | ||
|
|
a7afa4a0c3 | ||
|
|
004100091f | ||
|
|
20231ce198 | ||
|
|
0851a6d085 | ||
|
|
0cd36ad5bc | ||
|
|
7618dd0f91 | ||
|
|
cf49a2cb65 | ||
|
|
cbdce18633 | ||
|
|
a0d14eb1d3 | ||
|
|
53ce4d2453 | ||
|
|
1ddb041d6d | ||
|
|
43cbfd1c47 | ||
|
|
b9a8495a43 | ||
|
|
e296477880 | ||
|
|
bd5c2d8cbc | ||
|
|
ccd40d5c68 | ||
|
|
7f8ca4fad2 | ||
|
|
4bb9a7155d | ||
|
|
2ac79954f3 | ||
|
|
585e1f47f3 | ||
|
|
a33c474b35 | ||
|
|
61c3d8964b | ||
|
|
1c927c5820 | ||
|
|
ff0fa0329d | ||
|
|
e51ea439ca | ||
|
|
113977b19f | ||
|
|
8f39b50b6d | ||
|
|
95b309c358 | ||
|
|
cf3df3b715 | ||
|
|
d815028c4d | ||
|
|
ac5570abe2 | ||
|
|
84ad571aa4 | ||
|
|
38e7705ae7 | ||
|
|
0b6af014fa | ||
|
|
2401f2299d | ||
|
|
919768c8bb | ||
|
|
24db21463b | ||
|
|
1e029af83a | ||
|
|
53dd8ce606 | ||
|
|
0f4003366d | ||
|
|
ac6f3c267f | ||
|
|
39ad625fa1 | ||
|
|
1db67025bf | ||
|
|
13ab6c072a | ||
|
|
cec1dd84ef | ||
|
|
fae5805322 | ||
|
|
16ea9500be | ||
|
|
18f5dc0f47 | ||
|
|
ba3e941fe8 | ||
|
|
4c416b03b1 | ||
|
|
e2abb64171 | ||
|
|
c66aa13ae1 | ||
|
|
2b31be789d | ||
|
|
bf1b4bb549 | ||
|
|
3b539c8577 | ||
|
|
dd42b807f0 | ||
|
|
542fbafd98 | ||
|
|
37b9f5c882 | ||
|
|
4836559abe | ||
|
|
17b06c8845 | ||
|
|
8dd07b97c7 | ||
|
|
9e139495ac | ||
|
|
7fa76d6d37 | ||
|
|
a3cce35881 | ||
|
|
ed4f71a283 | ||
|
|
13e2f4e27d | ||
|
|
17343dfeae | ||
|
|
4b5978fb58 | ||
|
|
0a30eea3b4 | ||
|
|
a15d281c40 | ||
|
|
6846bb7cdc | ||
|
|
1d240a40dd | ||
|
|
c377bcec5f | ||
|
|
9b74fb4dbd | ||
|
|
6744c0c143 | ||
|
|
1e9f5e6430 | ||
|
|
ceaa064e62 | ||
|
|
1aad3e4512 | ||
|
|
f83c3c2811 | ||
|
|
a23ec6d318 | ||
|
|
ecc53888bc | ||
|
|
e54f72091f | ||
|
|
75b5b28804 | ||
|
|
f81a2ed237 | ||
|
|
49e01157e7 | ||
|
|
28420a729e | ||
|
|
52a4cf8d52 | ||
|
|
703c2392a9 | ||
|
|
18c9a66437 | ||
|
|
9687d57de9 | ||
|
|
60c2e57d83 | ||
|
|
b14bff0145 | ||
|
|
9166886665 | ||
|
|
c74010d441 | ||
|
|
640a21e4db | ||
|
|
fd442a5735 | ||
|
|
c7b99044bc | ||
|
|
234451a7d4 | ||
|
|
ffff904ab1 | ||
|
|
d71a26220c | ||
|
|
beeeb8dc5d | ||
|
|
19244cc4c6 | ||
|
|
cc94ba6b5e | ||
|
|
c9926cc877 | ||
|
|
1d14e1b0af | ||
|
|
297da44a5a | ||
|
|
402ff53a5c | ||
|
|
2d6e4a0df1 | ||
|
|
defcfa3316 | ||
|
|
3209b71b0a | ||
|
|
80b3ca0a1e | ||
|
|
8351bd2fa3 | ||
|
|
255966ed3b | ||
|
|
8d6ebf4770 | ||
|
|
2ca752bf78 | ||
|
|
79e1192f67 | ||
|
|
ff610efc84 | ||
|
|
6b68a739ef | ||
|
|
909bd0ba15 | ||
|
|
05110abc59 | ||
|
|
a64d99eb91 | ||
|
|
0e45403195 | ||
|
|
e16a9ffe65 | ||
|
|
57de122ef8 |
102
.gitlab-ci.yml
102
.gitlab-ci.yml
@@ -5,15 +5,16 @@
|
||||
- merge_requests
|
||||
|
||||
stages:
|
||||
- pre-commit
|
||||
- gitlab
|
||||
- test
|
||||
- deploy
|
||||
- docker
|
||||
- pre-commit
|
||||
- gitlab
|
||||
- test
|
||||
- deploy
|
||||
- docker
|
||||
|
||||
include:
|
||||
- template: Dependency-Scanning.gitlab-ci.yml
|
||||
- template: Security/SAST.gitlab-ci.yml
|
||||
- template: Dependency-Scanning.gitlab-ci.yml
|
||||
- template: Security/SAST.gitlab-ci.yml
|
||||
- template: Security/Secret-Detection.gitlab-ci.yml
|
||||
|
||||
before_script:
|
||||
- apt-get update && apt-get install redis-server -y
|
||||
@@ -24,7 +25,7 @@ before_script:
|
||||
pre-commit-check:
|
||||
<<: *only-default
|
||||
stage: pre-commit
|
||||
image: python:3.6-buster
|
||||
image: python:3.8-bullseye
|
||||
variables:
|
||||
PRE_COMMIT_HOME: ${CI_PROJECT_DIR}/.cache/pre-commit
|
||||
cache:
|
||||
@@ -41,28 +42,20 @@ sast:
|
||||
dependency_scanning:
|
||||
stage: gitlab
|
||||
before_script:
|
||||
- apt-get update && apt-get install redis-server libmariadb-dev -y
|
||||
- redis-server --daemonize yes
|
||||
- python -V
|
||||
- pip install wheel tox
|
||||
- apt-get update && apt-get install redis-server libmariadb-dev -y
|
||||
- redis-server --daemonize yes
|
||||
- python -V
|
||||
- pip install wheel tox
|
||||
|
||||
test-3.7-core:
|
||||
<<: *only-default
|
||||
image: python:3.7-bullseye
|
||||
script:
|
||||
- tox -e py37-core
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
secret_detection:
|
||||
stage: gitlab
|
||||
before_script: []
|
||||
|
||||
test-3.8-core:
|
||||
<<: *only-default
|
||||
image: python:3.8-bullseye
|
||||
script:
|
||||
- tox -e py38-core
|
||||
- tox -e py38-core
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -74,7 +67,7 @@ test-3.9-core:
|
||||
<<: *only-default
|
||||
image: python:3.9-bullseye
|
||||
script:
|
||||
- tox -e py39-core
|
||||
- tox -e py39-core
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -86,7 +79,7 @@ test-3.10-core:
|
||||
<<: *only-default
|
||||
image: python:3.10-bullseye
|
||||
script:
|
||||
- tox -e py310-core
|
||||
- tox -e py310-core
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -98,7 +91,7 @@ test-3.11-core:
|
||||
<<: *only-default
|
||||
image: python:3.11-rc-bullseye
|
||||
script:
|
||||
- tox -e py311-core
|
||||
- tox -e py311-core
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -107,23 +100,11 @@ test-3.11-core:
|
||||
path: coverage.xml
|
||||
allow_failure: true
|
||||
|
||||
test-3.7-all:
|
||||
<<: *only-default
|
||||
image: python:3.7-bullseye
|
||||
script:
|
||||
- tox -e py37-all
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
coverage_report:
|
||||
coverage_format: cobertura
|
||||
path: coverage.xml
|
||||
|
||||
test-3.8-all:
|
||||
<<: *only-default
|
||||
image: python:3.8-bullseye
|
||||
script:
|
||||
- tox -e py38-all
|
||||
- tox -e py38-all
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -135,7 +116,7 @@ test-3.9-all:
|
||||
<<: *only-default
|
||||
image: python:3.9-bullseye
|
||||
script:
|
||||
- tox -e py39-all
|
||||
- tox -e py39-all
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -147,7 +128,7 @@ test-3.10-all:
|
||||
<<: *only-default
|
||||
image: python:3.10-bullseye
|
||||
script:
|
||||
- tox -e py310-all
|
||||
- tox -e py310-all
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -159,7 +140,7 @@ test-3.11-all:
|
||||
<<: *only-default
|
||||
image: python:3.11-rc-bullseye
|
||||
script:
|
||||
- tox -e py311-all
|
||||
- tox -e py311-all
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
@@ -168,16 +149,43 @@ test-3.11-all:
|
||||
path: coverage.xml
|
||||
allow_failure: true
|
||||
|
||||
build-test:
|
||||
stage: test
|
||||
image: python:3.10-bullseye
|
||||
|
||||
before_script:
|
||||
- python -m pip install --upgrade pip
|
||||
- python -m pip install --upgrade build
|
||||
- python -m pip install --upgrade setuptools wheel
|
||||
|
||||
script:
|
||||
- python -m build
|
||||
|
||||
artifacts:
|
||||
when: always
|
||||
name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
|
||||
paths:
|
||||
- dist/*
|
||||
expire_in: 1 year
|
||||
|
||||
test-docs:
|
||||
<<: *only-default
|
||||
image: python:3.10-bullseye
|
||||
script:
|
||||
- tox -e docs
|
||||
|
||||
deploy_production:
|
||||
stage: deploy
|
||||
image: python:3.10-bullseye
|
||||
|
||||
before_script:
|
||||
- pip install twine wheel
|
||||
- python -m pip install --upgrade pip
|
||||
- python -m pip install --upgrade build
|
||||
- python -m pip install --upgrade setuptools wheel twine
|
||||
|
||||
script:
|
||||
- python setup.py sdist bdist_wheel
|
||||
- twine upload dist/*
|
||||
- python -m build
|
||||
- python -m twine upload dist/*
|
||||
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
@@ -205,6 +213,8 @@ build-image:
|
||||
docker image push --all-tags $CI_REGISTRY_IMAGE/auth
|
||||
rules:
|
||||
- if: $CI_COMMIT_TAG
|
||||
when: delayed
|
||||
start_in: 10 minutes
|
||||
|
||||
build-image-dev:
|
||||
before_script: []
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.0.1
|
||||
rev: v4.3.0
|
||||
hooks:
|
||||
- id: check-case-conflict
|
||||
- id: check-json
|
||||
@@ -22,13 +22,18 @@ repos:
|
||||
args: [ '--remove' ]
|
||||
|
||||
- repo: https://github.com/editorconfig-checker/editorconfig-checker.python
|
||||
rev: 2.3.54
|
||||
rev: 2.4.0
|
||||
hooks:
|
||||
- id: editorconfig-checker
|
||||
exclude: ^(LICENSE|allianceauth\/static\/css\/themes\/bootstrap-locals.less|allianceauth\/eveonline\/swagger.json|(.*.po)|(.*.mo))
|
||||
exclude: ^(LICENSE|allianceauth\/static\/allianceauth\/css\/themes\/bootstrap-locals.less|allianceauth\/eveonline\/swagger.json|(.*.po)|(.*.mo))
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v2.29.0
|
||||
rev: v2.34.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [ --py37-plus ]
|
||||
args: [ --py38-plus ]
|
||||
|
||||
- repo: https://github.com/asottile/setup-cfg-fmt
|
||||
rev: v1.20.1
|
||||
hooks:
|
||||
- id: setup-cfg-fmt
|
||||
|
||||
@@ -5,19 +5,22 @@
|
||||
# Required
|
||||
version: 2
|
||||
|
||||
# Set the version of Python and other tools you might need
|
||||
build:
|
||||
os: ubuntu-20.04
|
||||
apt_packages:
|
||||
- redis
|
||||
tools:
|
||||
python: "3.8"
|
||||
|
||||
# Build documentation in the docs/ directory with Sphinx
|
||||
sphinx:
|
||||
configuration: docs/conf.py
|
||||
|
||||
# Build documentation with MkDocs
|
||||
#mkdocs:
|
||||
# configuration: mkdocs.yml
|
||||
|
||||
# Optionally build your docs in additional formats such as PDF and ePub
|
||||
formats: all
|
||||
|
||||
# Optionally set the version of Python and requirements required to build your docs
|
||||
python:
|
||||
version: 3.7
|
||||
install:
|
||||
- requirements: docs/requirements.txt
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
# This will make sure the app is always imported when
|
||||
# Django starts so that shared_task will use this app.
|
||||
|
||||
__version__ = '2.12.0'
|
||||
__version__ = '3.1.1'
|
||||
__title__ = 'Alliance Auth'
|
||||
__url__ = 'https://gitlab.com/allianceauth/allianceauth'
|
||||
NAME = f'{__title__} v{__version__}'
|
||||
default_app_config = 'allianceauth.apps.AllianceAuthConfig'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.analytics.apps.AnalyticsConfig'
|
||||
|
||||
@@ -3,16 +3,17 @@ from urllib.parse import parse_qs
|
||||
|
||||
import requests_mock
|
||||
|
||||
from django.test import TestCase, override_settings
|
||||
from django.test import override_settings
|
||||
|
||||
from allianceauth.analytics.tasks import ANALYTICS_URL
|
||||
from allianceauth.eveonline.tasks import update_character
|
||||
from allianceauth.tests.auth_utils import AuthUtils
|
||||
from allianceauth.utils.testing import NoSocketsTestCase
|
||||
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True)
|
||||
@requests_mock.mock()
|
||||
class TestAnalyticsForViews(TestCase):
|
||||
class TestAnalyticsForViews(NoSocketsTestCase):
|
||||
@override_settings(ANALYTICS_DISABLED=False)
|
||||
def test_should_run_analytics(self, requests_mocker):
|
||||
# given
|
||||
@@ -40,7 +41,7 @@ class TestAnalyticsForViews(TestCase):
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True)
|
||||
@requests_mock.mock()
|
||||
class TestAnalyticsForTasks(TestCase):
|
||||
class TestAnalyticsForTasks(NoSocketsTestCase):
|
||||
@override_settings(ANALYTICS_DISABLED=False)
|
||||
@patch("allianceauth.eveonline.models.EveCharacter.objects.update_character")
|
||||
def test_should_run_analytics_for_successful_task(
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from allianceauth.analytics.middleware import AnalyticsMiddleware
|
||||
from unittest.mock import Mock
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.test.testcases import TestCase
|
||||
|
||||
@@ -7,7 +8,7 @@ from django.test.testcases import TestCase
|
||||
class TestAnalyticsMiddleware(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.middleware = AnalyticsMiddleware()
|
||||
self.middleware = AnalyticsMiddleware(HttpResponse)
|
||||
self.request = Mock()
|
||||
self.request.headers = {
|
||||
"User-Agent": "AUTOMATED TEST"
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
import requests_mock
|
||||
|
||||
from django.test.utils import override_settings
|
||||
|
||||
from allianceauth.analytics.tasks import (
|
||||
analytics_event,
|
||||
send_ga_tracking_celery_event,
|
||||
send_ga_tracking_web_view)
|
||||
from django.test.testcases import TestCase
|
||||
from allianceauth.utils.testing import NoSocketsTestCase
|
||||
|
||||
|
||||
class TestAnalyticsTasks(TestCase):
|
||||
def test_analytics_event(self):
|
||||
GOOGLE_ANALYTICS_DEBUG_URL = 'https://www.google-analytics.com/debug/collect'
|
||||
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True)
|
||||
@requests_mock.Mocker()
|
||||
class TestAnalyticsTasks(NoSocketsTestCase):
|
||||
def test_analytics_event(self, requests_mocker):
|
||||
requests_mocker.register_uri('POST', GOOGLE_ANALYTICS_DEBUG_URL)
|
||||
analytics_event(
|
||||
category='allianceauth.analytics',
|
||||
action='send_tests',
|
||||
@@ -14,15 +24,19 @@ class TestAnalyticsTasks(TestCase):
|
||||
value=1,
|
||||
event_type='Stats')
|
||||
|
||||
def test_send_ga_tracking_web_view_sent(self):
|
||||
# This test sends if the event SENDS to google
|
||||
# Not if it was successful
|
||||
def test_send_ga_tracking_web_view_sent(self, requests_mocker):
|
||||
"""This test sends if the event SENDS to google.
|
||||
Not if it was successful.
|
||||
"""
|
||||
# given
|
||||
requests_mocker.register_uri('POST', GOOGLE_ANALYTICS_DEBUG_URL)
|
||||
tracking_id = 'UA-186249766-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
page = '/index/'
|
||||
title = 'Hello World'
|
||||
locale = 'en'
|
||||
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
||||
# when
|
||||
response = send_ga_tracking_web_view(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -30,15 +44,23 @@ class TestAnalyticsTasks(TestCase):
|
||||
title,
|
||||
locale,
|
||||
useragent)
|
||||
# then
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_send_ga_tracking_web_view_success(self):
|
||||
def test_send_ga_tracking_web_view_success(self, requests_mocker):
|
||||
# given
|
||||
requests_mocker.register_uri(
|
||||
'POST',
|
||||
GOOGLE_ANALYTICS_DEBUG_URL,
|
||||
json={"hitParsingResult":[{'valid': True}]}
|
||||
)
|
||||
tracking_id = 'UA-186249766-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
page = '/index/'
|
||||
title = 'Hello World'
|
||||
locale = 'en'
|
||||
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
||||
# when
|
||||
json_response = send_ga_tracking_web_view(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -46,15 +68,42 @@ class TestAnalyticsTasks(TestCase):
|
||||
title,
|
||||
locale,
|
||||
useragent).json()
|
||||
# then
|
||||
self.assertTrue(json_response["hitParsingResult"][0]["valid"])
|
||||
|
||||
def test_send_ga_tracking_web_view_invalid_token(self):
|
||||
def test_send_ga_tracking_web_view_invalid_token(self, requests_mocker):
|
||||
# given
|
||||
requests_mocker.register_uri(
|
||||
'POST',
|
||||
GOOGLE_ANALYTICS_DEBUG_URL,
|
||||
json={
|
||||
"hitParsingResult":[
|
||||
{
|
||||
'valid': False,
|
||||
'parserMessage': [
|
||||
{
|
||||
'messageType': 'INFO',
|
||||
'description': 'IP Address from this hit was anonymized to 1.132.110.0.',
|
||||
'messageCode': 'VALUE_MODIFIED'
|
||||
},
|
||||
{
|
||||
'messageType': 'ERROR',
|
||||
'description': "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.",
|
||||
'messageCode': 'VALUE_INVALID', 'parameter': 'tid'
|
||||
}
|
||||
],
|
||||
'hit': '/debug/collect?v=1&tid=UA-IntentionallyBadTrackingID-2&cid=ab33e241fbf042b6aa77c7655a768af7&t=pageview&dp=/index/&dt=Hello World&ul=en&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&aip=1&an=allianceauth&av=2.9.0a2'
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
tracking_id = 'UA-IntentionallyBadTrackingID-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
page = '/index/'
|
||||
title = 'Hello World'
|
||||
locale = 'en'
|
||||
useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
|
||||
# when
|
||||
json_response = send_ga_tracking_web_view(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -62,18 +111,25 @@ class TestAnalyticsTasks(TestCase):
|
||||
title,
|
||||
locale,
|
||||
useragent).json()
|
||||
# then
|
||||
self.assertFalse(json_response["hitParsingResult"][0]["valid"])
|
||||
self.assertEqual(json_response["hitParsingResult"][0]["parserMessage"][1]["description"], "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.")
|
||||
self.assertEqual(
|
||||
json_response["hitParsingResult"][0]["parserMessage"][1]["description"],
|
||||
"The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details."
|
||||
)
|
||||
|
||||
# [{'valid': False, 'parserMessage': [{'messageType': 'INFO', 'description': 'IP Address from this hit was anonymized to 1.132.110.0.', 'messageCode': 'VALUE_MODIFIED'}, {'messageType': 'ERROR', 'description': "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.", 'messageCode': 'VALUE_INVALID', 'parameter': 'tid'}], 'hit': '/debug/collect?v=1&tid=UA-IntentionallyBadTrackingID-2&cid=ab33e241fbf042b6aa77c7655a768af7&t=pageview&dp=/index/&dt=Hello World&ul=en&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&aip=1&an=allianceauth&av=2.9.0a2'}]
|
||||
|
||||
def test_send_ga_tracking_celery_event_sent(self):
|
||||
def test_send_ga_tracking_celery_event_sent(self, requests_mocker):
|
||||
# given
|
||||
requests_mocker.register_uri('POST', GOOGLE_ANALYTICS_DEBUG_URL)
|
||||
tracking_id = 'UA-186249766-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
category = 'test'
|
||||
action = 'test'
|
||||
label = 'test'
|
||||
value = '1'
|
||||
# when
|
||||
response = send_ga_tracking_celery_event(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -81,15 +137,23 @@ class TestAnalyticsTasks(TestCase):
|
||||
action,
|
||||
label,
|
||||
value)
|
||||
# then
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_send_ga_tracking_celery_event_success(self):
|
||||
def test_send_ga_tracking_celery_event_success(self, requests_mocker):
|
||||
# given
|
||||
requests_mocker.register_uri(
|
||||
'POST',
|
||||
GOOGLE_ANALYTICS_DEBUG_URL,
|
||||
json={"hitParsingResult":[{'valid': True}]}
|
||||
)
|
||||
tracking_id = 'UA-186249766-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
category = 'test'
|
||||
action = 'test'
|
||||
label = 'test'
|
||||
value = '1'
|
||||
# when
|
||||
json_response = send_ga_tracking_celery_event(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -97,15 +161,42 @@ class TestAnalyticsTasks(TestCase):
|
||||
action,
|
||||
label,
|
||||
value).json()
|
||||
# then
|
||||
self.assertTrue(json_response["hitParsingResult"][0]["valid"])
|
||||
|
||||
def test_send_ga_tracking_celery_event_invalid_token(self):
|
||||
def test_send_ga_tracking_celery_event_invalid_token(self, requests_mocker):
|
||||
# given
|
||||
requests_mocker.register_uri(
|
||||
'POST',
|
||||
GOOGLE_ANALYTICS_DEBUG_URL,
|
||||
json={
|
||||
"hitParsingResult":[
|
||||
{
|
||||
'valid': False,
|
||||
'parserMessage': [
|
||||
{
|
||||
'messageType': 'INFO',
|
||||
'description': 'IP Address from this hit was anonymized to 1.132.110.0.',
|
||||
'messageCode': 'VALUE_MODIFIED'
|
||||
},
|
||||
{
|
||||
'messageType': 'ERROR',
|
||||
'description': "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.",
|
||||
'messageCode': 'VALUE_INVALID', 'parameter': 'tid'
|
||||
}
|
||||
],
|
||||
'hit': '/debug/collect?v=1&tid=UA-IntentionallyBadTrackingID-2&cid=ab33e241fbf042b6aa77c7655a768af7&t=pageview&dp=/index/&dt=Hello World&ul=en&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&aip=1&an=allianceauth&av=2.9.0a2'
|
||||
}
|
||||
]
|
||||
}
|
||||
)
|
||||
tracking_id = 'UA-IntentionallyBadTrackingID-2'
|
||||
client_id = 'ab33e241fbf042b6aa77c7655a768af7'
|
||||
category = 'test'
|
||||
action = 'test'
|
||||
label = 'test'
|
||||
value = '1'
|
||||
# when
|
||||
json_response = send_ga_tracking_celery_event(
|
||||
tracking_id,
|
||||
client_id,
|
||||
@@ -113,7 +204,9 @@ class TestAnalyticsTasks(TestCase):
|
||||
action,
|
||||
label,
|
||||
value).json()
|
||||
# then
|
||||
self.assertFalse(json_response["hitParsingResult"][0]["valid"])
|
||||
self.assertEqual(json_response["hitParsingResult"][0]["parserMessage"][1]["description"], "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.")
|
||||
|
||||
# [{'valid': False, 'parserMessage': [{'messageType': 'INFO', 'description': 'IP Address from this hit was anonymized to 1.132.110.0.', 'messageCode': 'VALUE_MODIFIED'}, {'messageType': 'ERROR', 'description': "The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details.", 'messageCode': 'VALUE_INVALID', 'parameter': 'tid'}], 'hit': '/debug/collect?v=1&tid=UA-IntentionallyBadTrackingID-2&cid=ab33e241fbf042b6aa77c7655a768af7&t=pageview&dp=/index/&dt=Hello World&ul=en&ua=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&aip=1&an=allianceauth&av=2.9.0a2'}]
|
||||
self.assertEqual(
|
||||
json_response["hitParsingResult"][0]["parserMessage"][1]["description"],
|
||||
"The value provided for parameter 'tid' is invalid. Please see http://goo.gl/a8d4RP#tid for details."
|
||||
)
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.authentication.apps.AuthenticationConfig'
|
||||
|
||||
@@ -322,7 +322,7 @@ class UserAdmin(BaseUserAdmin):
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
"all": ("authentication/css/admin.css",)
|
||||
"all": ("allianceauth/authentication/css/admin.css",)
|
||||
}
|
||||
|
||||
def get_queryset(self, request):
|
||||
@@ -542,7 +542,7 @@ class BaseOwnershipAdmin(admin.ModelAdmin):
|
||||
|
||||
class Media:
|
||||
css = {
|
||||
"all": ("authentication/css/admin.css",)
|
||||
"all": ("allianceauth/authentication/css/admin.css",)
|
||||
}
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
from django.conf.urls import url, include
|
||||
from django.conf.urls import include
|
||||
|
||||
from allianceauth.authentication import views
|
||||
from django.urls import re_path
|
||||
from django.urls import path
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^activate/complete/$', views.activation_complete, name='registration_activation_complete'),
|
||||
path('activate/complete/', views.activation_complete, name='registration_activation_complete'),
|
||||
# The activation key can make use of any character from the
|
||||
# URL-safe base64 alphabet, plus the colon as a separator.
|
||||
url(r'^activate/(?P<activation_key>[-:\w]+)/$', views.ActivationView.as_view(), name='registration_activate'),
|
||||
url(r'^register/$', views.RegistrationView.as_view(), name='registration_register'),
|
||||
url(r'^register/complete/$', views.registration_complete, name='registration_complete'),
|
||||
url(r'^register/closed/$', views.registration_closed, name='registration_disallowed'),
|
||||
url(r'', include('django.contrib.auth.urls')),
|
||||
re_path(r'^activate/(?P<activation_key>[-:\w]+)/$', views.ActivationView.as_view(), name='registration_activate'),
|
||||
path('register/', views.RegistrationView.as_view(), name='registration_register'),
|
||||
path('register/complete/', views.registration_complete, name='registration_complete'),
|
||||
path('register/closed/', views.registration_closed, name='registration_disallowed'),
|
||||
path('', include('django.contrib.auth.urls')),
|
||||
]
|
||||
|
||||
45
allianceauth/authentication/middleware.py
Normal file
45
allianceauth/authentication/middleware.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from django.conf import settings
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class UserSettingsMiddleware(MiddlewareMixin):
|
||||
def process_response(self, request, response):
|
||||
"""Django Middleware: User Settings."""
|
||||
|
||||
# Intercept the built in django /setlang/ view and also save it to Database.
|
||||
# Note the annoymous user check, only logged in users will ever hit the DB here
|
||||
if request.path == '/i18n/setlang/' and not request.user.is_anonymous:
|
||||
try:
|
||||
request.user.profile.language = request.POST['language']
|
||||
request.user.profile.save()
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
# Only act during the login flow, _after_ user is activated (step 2: post-sso)
|
||||
elif request.path == '/sso/login' and not request.user.is_anonymous:
|
||||
# Set the Language Cookie, if it doesnt match the DB
|
||||
# Null = hasnt been set by the user ever, dont act.
|
||||
try:
|
||||
if request.user.profile.language != request.LANGUAGE_CODE and request.user.profile.language is not None:
|
||||
response.set_cookie(key=settings.LANGUAGE_COOKIE_NAME,
|
||||
value=request.user.profile.language,
|
||||
max_age=settings.LANGUAGE_COOKIE_AGE)
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
# Set our Night mode flag from the DB
|
||||
# Null = hasnt been set by the user ever, dont act.
|
||||
#
|
||||
# Night mode intercept is not needed in this middleware.
|
||||
# is saved direct to DB in NightModeRedirectView
|
||||
try:
|
||||
if request.user.profile.night_mode is not None:
|
||||
request.session["NIGHT_MODE"] = request.user.profile.night_mode
|
||||
except Exception as e:
|
||||
logger.exception(e)
|
||||
|
||||
return response
|
||||
@@ -0,0 +1,23 @@
|
||||
# Generated by Django 4.0.2 on 2022-02-26 03:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('authentication', '0019_merge_20211026_0919'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='userprofile',
|
||||
name='language',
|
||||
field=models.CharField(blank=True, choices=[('en', 'English'), ('de', 'German'), ('es', 'Spanish'), ('zh-hans', 'Chinese Simplified'), ('ru', 'Russian'), ('ko', 'Korean'), ('fr', 'French'), ('ja', 'Japanese'), ('it', 'Italian')], default='', max_length=10, verbose_name='Language'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='userprofile',
|
||||
name='night_mode',
|
||||
field=models.BooleanField(blank=True, null=True, verbose_name='Night Mode'),
|
||||
),
|
||||
]
|
||||
@@ -2,9 +2,10 @@ import logging
|
||||
|
||||
from django.contrib.auth.models import User, Permission
|
||||
from django.db import models, transaction
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo, EveAllianceInfo, EveFactionInfo
|
||||
from allianceauth.notifications import notify
|
||||
from django.conf import settings
|
||||
|
||||
from .managers import CharacterOwnershipManager, StateManager
|
||||
|
||||
@@ -62,9 +63,39 @@ class UserProfile(models.Model):
|
||||
class Meta:
|
||||
default_permissions = ('change',)
|
||||
|
||||
user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE)
|
||||
main_character = models.OneToOneField(EveCharacter, blank=True, null=True, on_delete=models.SET_NULL)
|
||||
state = models.ForeignKey(State, on_delete=models.SET_DEFAULT, default=get_guest_state_pk)
|
||||
user = models.OneToOneField(
|
||||
User,
|
||||
related_name='profile',
|
||||
on_delete=models.CASCADE)
|
||||
main_character = models.OneToOneField(
|
||||
EveCharacter,
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=models.SET_NULL)
|
||||
state = models.ForeignKey(
|
||||
State,
|
||||
on_delete=models.SET_DEFAULT,
|
||||
default=get_guest_state_pk)
|
||||
LANGUAGE_CHOICES = [
|
||||
('en', _('English')),
|
||||
('de', _('German')),
|
||||
('es', _('Spanish')),
|
||||
('zh-hans', _('Chinese Simplified')),
|
||||
('ru', _('Russian')),
|
||||
('ko', _('Korean')),
|
||||
('fr', _('French')),
|
||||
('ja', _('Japanese')),
|
||||
('it', _('Italian')),
|
||||
]
|
||||
language = models.CharField(
|
||||
_("Language"), max_length=10,
|
||||
choices=LANGUAGE_CHOICES,
|
||||
blank=True,
|
||||
default='')
|
||||
night_mode = models.BooleanField(
|
||||
_("Night Mode"),
|
||||
blank=True,
|
||||
null=True)
|
||||
|
||||
def assign_state(self, state=None, commit=True):
|
||||
if not state:
|
||||
@@ -93,8 +124,6 @@ class UserProfile(models.Model):
|
||||
|
||||
def __str__(self):
|
||||
return str(self.user)
|
||||
|
||||
|
||||
class CharacterOwnership(models.Model):
|
||||
class Meta:
|
||||
default_permissions = ('change', 'delete')
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
import logging
|
||||
|
||||
from .models import CharacterOwnership, UserProfile, get_guest_state, State, OwnershipRecord
|
||||
from .models import (
|
||||
CharacterOwnership,
|
||||
UserProfile,
|
||||
get_guest_state,
|
||||
State,
|
||||
OwnershipRecord)
|
||||
from django.contrib.auth.models import User
|
||||
from django.db.models import Q
|
||||
from django.db.models.signals import pre_save, post_save, pre_delete, post_delete, m2m_changed
|
||||
@@ -11,7 +16,7 @@ from allianceauth.eveonline.models import EveCharacter
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
state_changed = Signal(providing_args=['user', 'state'])
|
||||
state_changed = Signal()
|
||||
|
||||
|
||||
def trigger_state_check(state):
|
||||
@@ -71,7 +76,7 @@ def reassess_on_profile_save(sender, instance, created, *args, **kwargs):
|
||||
|
||||
@receiver(post_save, sender=User)
|
||||
def create_required_models(sender, instance, created, *args, **kwargs):
|
||||
# ensure all users have a model
|
||||
# ensure all users have our Sub-Models
|
||||
if created:
|
||||
logger.debug(f'User {instance} created. Creating default UserProfile.')
|
||||
UserProfile.objects.get_or_create(user=instance)
|
||||
|
||||
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
@@ -1,27 +1,62 @@
|
||||
import datetime as dt
|
||||
from typing import Optional, List
|
||||
import logging
|
||||
from typing import List, Optional
|
||||
|
||||
from redis import Redis
|
||||
from pytz import utc
|
||||
from redis import Redis, RedisError
|
||||
|
||||
from django.core.cache import cache
|
||||
from allianceauth.utils.cache import get_redis_client
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class _RedisStub:
|
||||
"""Stub of a Redis client.
|
||||
|
||||
It's purpose is to prevent EventSeries objects from trying to access Redis
|
||||
when it is not available. e.g. when the Sphinx docs are rendered by readthedocs.org.
|
||||
"""
|
||||
|
||||
def delete(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def incr(self, *args, **kwargs):
|
||||
return 0
|
||||
|
||||
def zadd(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def zcount(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
def zrangebyscore(self, *args, **kwargs):
|
||||
pass
|
||||
|
||||
|
||||
class EventSeries:
|
||||
"""API for recording and analysing a series of events."""
|
||||
"""API for recording and analyzing a series of events."""
|
||||
|
||||
_ROOT_KEY = "ALLIANCEAUTH_EVENT_SERIES"
|
||||
|
||||
def __init__(self, key_id: str, redis: Redis = None) -> None:
|
||||
self._redis = cache.get_master_client() if not redis else redis
|
||||
if not isinstance(self._redis, Redis):
|
||||
raise TypeError(
|
||||
"This class requires a Redis client, but none was provided "
|
||||
"and the default Django cache backend is not Redis either."
|
||||
self._redis = get_redis_client() if not redis else redis
|
||||
try:
|
||||
if not self._redis.ping():
|
||||
raise RuntimeError()
|
||||
except (AttributeError, RedisError, RuntimeError):
|
||||
logger.exception(
|
||||
"Failed to establish a connection with Redis. "
|
||||
"This EventSeries object is disabled.",
|
||||
)
|
||||
self._redis = _RedisStub()
|
||||
self._key_id = str(key_id)
|
||||
self.clear()
|
||||
|
||||
@property
|
||||
def is_disabled(self):
|
||||
"""True when this object is disabled, e.g. Redis was not available at startup."""
|
||||
return isinstance(self._redis, _RedisStub)
|
||||
|
||||
@property
|
||||
def _key_counter(self):
|
||||
return f"{self._ROOT_KEY}_{self._key_id}_COUNTER"
|
||||
|
||||
@@ -1,13 +1,48 @@
|
||||
import datetime as dt
|
||||
from unittest.mock import patch
|
||||
|
||||
from pytz import utc
|
||||
from redis import RedisError
|
||||
|
||||
from django.test import TestCase
|
||||
from django.utils.timezone import now
|
||||
|
||||
from allianceauth.authentication.task_statistics.event_series import EventSeries
|
||||
from allianceauth.authentication.task_statistics.event_series import (
|
||||
EventSeries,
|
||||
_RedisStub,
|
||||
)
|
||||
|
||||
MODULE_PATH = "allianceauth.authentication.task_statistics.event_series"
|
||||
|
||||
|
||||
class TestEventSeries(TestCase):
|
||||
def test_should_abort_without_redis_client(self):
|
||||
# when
|
||||
with patch(MODULE_PATH + ".get_redis_client") as mock:
|
||||
mock.return_value = None
|
||||
events = EventSeries("dummy")
|
||||
# then
|
||||
self.assertTrue(events._redis, _RedisStub)
|
||||
self.assertTrue(events.is_disabled)
|
||||
|
||||
def test_should_disable_itself_if_redis_not_available_1(self):
|
||||
# when
|
||||
with patch(MODULE_PATH + ".get_redis_client") as mock_get_master_client:
|
||||
mock_get_master_client.return_value.ping.side_effect = RedisError
|
||||
events = EventSeries("dummy")
|
||||
# then
|
||||
self.assertIsInstance(events._redis, _RedisStub)
|
||||
self.assertTrue(events.is_disabled)
|
||||
|
||||
def test_should_disable_itself_if_redis_not_available_2(self):
|
||||
# when
|
||||
with patch(MODULE_PATH + ".get_redis_client") as mock_get_master_client:
|
||||
mock_get_master_client.return_value.ping.return_value = False
|
||||
events = EventSeries("dummy")
|
||||
# then
|
||||
self.assertIsInstance(events._redis, _RedisStub)
|
||||
self.assertTrue(events.is_disabled)
|
||||
|
||||
def test_should_add_event(self):
|
||||
# given
|
||||
events = EventSeries("dummy")
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Dashboard" %}{% endblock %}
|
||||
@@ -28,7 +27,7 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar"src="{{ main.portrait_url_128 }}">
|
||||
<img class="ra-avatar" src="{{ main.portrait_url_128 }}" alt="{{ main.character_name }}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -40,7 +39,7 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar"src="{{ main.corporation_logo_url_128 }}">
|
||||
<img class="ra-avatar" src="{{ main.corporation_logo_url_128 }}" alt="{{ main.corporation_name }}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -53,7 +52,7 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar"src="{{ main.alliance_logo_url_128 }}">
|
||||
<img class="ra-avatar" src="{{ main.alliance_logo_url_128 }}" alt="{{ main.alliance_name }}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -64,7 +63,7 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar"src="{{ main.faction_logo_url_128 }}">
|
||||
<img class="ra-avatar" src="{{ main.faction_logo_url_128 }}" alt="{{ main.faction_name }}">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -76,13 +75,13 @@
|
||||
</div>
|
||||
<div class="table visible-xs-block">
|
||||
<p>
|
||||
<img class="ra-avatar" src="{{ main.portrait_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ main.corporation_logo_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ main.portrait_url_64 }}" alt="{{ main.corporation_name }}">
|
||||
<img class="ra-avatar" src="{{ main.corporation_logo_url_64 }}" alt="{{ main.corporation_name }}">
|
||||
{% if main.alliance_id %}
|
||||
<img class="ra-avatar" src="{{ main.alliance_logo_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ main.alliance_logo_url_64 }}" alt="{{ main.alliance_name }}">
|
||||
{% endif %}
|
||||
{% if main.faction_id %}
|
||||
<img class="ra-avatar" src="{{ main.faction_logo_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ main.faction_logo_url_64 }}" alt="{{ main.faction_name }}">
|
||||
{% endif %}
|
||||
</p>
|
||||
<p>
|
||||
@@ -122,7 +121,7 @@
|
||||
<h3 class="panel-title">{% translate "Group Memberships" %}</h3>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<div style="height: 240px;overflow:-moz-scrollbars-vertical;overflow-y:auto;">
|
||||
<div style="height: 240px;overflow-y:auto;">
|
||||
<table class="table table-aa">
|
||||
{% for group in groups %}
|
||||
<tr>
|
||||
@@ -155,7 +154,8 @@
|
||||
<tbody>
|
||||
{% for char in characters %}
|
||||
<tr>
|
||||
<td class="text-center"><img class="ra-avatar img-circle" src="{{ char.portrait_url_32 }}">
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar img-circle" src="{{ char.portrait_url_32 }}" alt="{{ char.character_name }}">
|
||||
</td>
|
||||
<td class="text-center">{{ char.character_name }}</td>
|
||||
<td class="text-center">{{ char.corporation_name }}</td>
|
||||
@@ -169,7 +169,7 @@
|
||||
{% for char in characters %}
|
||||
<tr>
|
||||
<td class="text-center" style="vertical-align: middle">
|
||||
<img class="ra-avatar img-circle" src="{{ char.portrait_url_32 }}">
|
||||
<img class="ra-avatar img-circle" src="{{ char.portrait_url_32 }}" alt="{{ char.character_name }}">
|
||||
</td>
|
||||
<td class="text-center" style="vertical-align: middle; width: 100%">
|
||||
<strong>{{ char.character_name }}</strong><br>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
<meta property="og:title" content="{{ SITE_NAME }}">
|
||||
<meta property="og:image" content="{{ request.scheme }}://{{ request.get_host }}{% static 'icons/apple-touch-icon.png' %}">
|
||||
<meta property="og:image" content="{{ request.scheme }}://{{ request.get_host }}{% static 'allianceauth/icons/apple-touch-icon.png' %}">
|
||||
<meta property="og:description" content="Alliance Auth - An auth system for EVE Online to help in-game organizations manage online service access.">
|
||||
|
||||
{% include 'allianceauth/icons.html' %}
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<style>
|
||||
body {
|
||||
background: url('{% static 'authentication/img/background.jpg' %}') no-repeat center center fixed;
|
||||
background: url('{% static 'allianceauth/authentication/img/background.jpg' %}') no-repeat center center fixed;
|
||||
-webkit-background-size: cover;
|
||||
-moz-background-size: cover;
|
||||
-o-background-size: cover;
|
||||
@@ -47,7 +47,7 @@
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container" style="margin-top:150px">
|
||||
<div class="container" style="margin-top:150px;">
|
||||
{% block content %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
|
||||
@@ -7,6 +7,6 @@
|
||||
|
||||
{% block middle_box_content %}
|
||||
<a href="{% url 'auth_sso_login' %}{% if request.GET.next %}?next={{request.GET.next}}{%endif%}">
|
||||
<img class="img-responsive center-block" src="{% static 'img/sso/EVE_SSO_Login_Buttons_Large_Black.png' %}" border=0>
|
||||
<img class="img-responsive center-block" src="{% static 'allianceauth/authentication/img/sso/EVE_SSO_Login_Buttons_Large_Black.png' %}" alt="{% translate 'Login with Eve SSO' %}">
|
||||
</a>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends 'public/base.html' %}
|
||||
{% load static %}
|
||||
{% block content %}
|
||||
<div class="col-md-4 col-md-offset-4">
|
||||
{% if messages %}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends 'public/base.html' %}
|
||||
|
||||
{% load static %}
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
{% load i18n %}{% autoescape off %}
|
||||
{% blocktrans trimmed %}You're receiving this email because you requested a password reset for your
|
||||
user account.{% endblocktrans %}
|
||||
|
||||
{% translate "Please go to the following page and choose a new password:" %}
|
||||
{% block reset_link %}
|
||||
{{domain}}{% url 'password_reset_confirm' uidb64=uid token=token %}
|
||||
{% endblock %}
|
||||
{% translate "Your username, in case you've forgotten:" %} {{ user.get_username }}
|
||||
|
||||
{% translate "Thanks for using our site!" %}
|
||||
|
||||
{% blocktrans %}Your IT Team{% endblocktrans %}
|
||||
|
||||
{% endautoescape %}
|
||||
@@ -1,14 +0,0 @@
|
||||
{% extends 'public/middle_box.html' %}
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
{% load static %}
|
||||
{% block page_title %}{% translate "Register" %}{% endblock %}
|
||||
{% block middle_box_content %}
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Submit" %}</button>
|
||||
<br/>
|
||||
</form>
|
||||
{% endblock %}
|
||||
@@ -1,4 +1,17 @@
|
||||
from django.db.models.signals import (
|
||||
m2m_changed,
|
||||
post_save,
|
||||
pre_delete,
|
||||
pre_save
|
||||
)
|
||||
from django.urls import reverse
|
||||
from unittest import mock
|
||||
|
||||
MODULE_PATH = 'allianceauth.authentication'
|
||||
|
||||
|
||||
def patch(target, *args, **kwargs):
|
||||
return mock.patch(f'{MODULE_PATH}{target}', *args, **kwargs)
|
||||
|
||||
|
||||
def get_admin_change_view_url(obj: object) -> str:
|
||||
|
||||
175
allianceauth/authentication/tests/test_middleware.py
Normal file
175
allianceauth/authentication/tests/test_middleware.py
Normal file
@@ -0,0 +1,175 @@
|
||||
from unittest import mock
|
||||
from allianceauth.authentication.middleware import UserSettingsMiddleware
|
||||
from unittest.mock import Mock
|
||||
from django.http import HttpResponse
|
||||
|
||||
from django.test.testcases import TestCase
|
||||
|
||||
|
||||
class TestUserSettingsMiddlewareSaveLang(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.middleware = UserSettingsMiddleware(HttpResponse)
|
||||
self.request = Mock()
|
||||
self.request.headers = {
|
||||
"User-Agent": "AUTOMATED TEST"
|
||||
}
|
||||
self.request.path = '/i18n/setlang/'
|
||||
self.request.POST = {
|
||||
'language': 'fr'
|
||||
}
|
||||
self.request.user.profile.language = 'de'
|
||||
self.request.user.is_anonymous = False
|
||||
self.response = Mock()
|
||||
self.response.content = 'hello world'
|
||||
|
||||
def test_middleware_passthrough(self):
|
||||
"""
|
||||
Simply tests the middleware runs cleanly
|
||||
"""
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.response, response)
|
||||
|
||||
def test_middleware_save_language_false_anonymous(self):
|
||||
"""
|
||||
Ensures the middleware wont change the usersettings
|
||||
of a non-existent (anonymous) user
|
||||
"""
|
||||
self.request.user.is_anonymous = True
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.request.user.profile.language, 'de')
|
||||
self.assertFalse(self.request.user.profile.save.called)
|
||||
self.assertEqual(self.request.user.profile.save.call_count, 0)
|
||||
|
||||
def test_middleware_save_language_new(self):
|
||||
"""
|
||||
does the middleware change a language not set in the DB
|
||||
"""
|
||||
self.request.user.profile.language = None
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.request.user.profile.language, 'fr')
|
||||
self.assertTrue(self.request.user.profile.save.called)
|
||||
self.assertEqual(self.request.user.profile.save.call_count, 1)
|
||||
|
||||
def test_middleware_save_language_changed(self):
|
||||
"""
|
||||
Tests the middleware will change a language setting
|
||||
"""
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.request.user.profile.language, 'fr')
|
||||
self.assertTrue(self.request.user.profile.save.called)
|
||||
self.assertEqual(self.request.user.profile.save.call_count, 1)
|
||||
|
||||
|
||||
class TestUserSettingsMiddlewareLoginFlow(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.middleware = UserSettingsMiddleware(HttpResponse)
|
||||
self.request = Mock()
|
||||
self.request.headers = {
|
||||
"User-Agent": "AUTOMATED TEST"
|
||||
}
|
||||
self.request.path = '/sso/login'
|
||||
self.request.session = {
|
||||
'NIGHT_MODE': False
|
||||
}
|
||||
self.request.LANGUAGE_CODE = 'en'
|
||||
self.request.user.profile.language = 'de'
|
||||
self.request.user.profile.night_mode = True
|
||||
self.request.user.is_anonymous = False
|
||||
self.response = Mock()
|
||||
self.response.content = 'hello world'
|
||||
|
||||
def test_middleware_passthrough(self):
|
||||
"""
|
||||
Simply tests the middleware runs cleanly
|
||||
"""
|
||||
middleware_response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.response, middleware_response)
|
||||
|
||||
def test_middleware_sets_language_cookie_true_no_cookie(self):
|
||||
"""
|
||||
tests the middleware will set a cookie, while none is set
|
||||
"""
|
||||
self.request.LANGUAGE_CODE = None
|
||||
middleware_response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertTrue(middleware_response.set_cookie.called)
|
||||
self.assertEqual(middleware_response.set_cookie.call_count, 1)
|
||||
args, kwargs = middleware_response.set_cookie.call_args
|
||||
self.assertEqual(kwargs['value'], 'de')
|
||||
|
||||
def test_middleware_sets_language_cookie_true_wrong_cookie(self):
|
||||
"""
|
||||
tests the middleware will set a cookie, while a different value is set
|
||||
"""
|
||||
middleware_response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertTrue(middleware_response.set_cookie.called)
|
||||
self.assertEqual(middleware_response.set_cookie.call_count, 1)
|
||||
args, kwargs = middleware_response.set_cookie.call_args
|
||||
self.assertEqual(kwargs['value'], 'de')
|
||||
|
||||
def test_middleware_sets_language_cookie_false_anonymous(self):
|
||||
"""
|
||||
ensures the middleware wont set a value for a non existent user (anonymous)
|
||||
"""
|
||||
self.request.user.is_anonymous = True
|
||||
middleware_response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertFalse = middleware_response.set_cookie.called
|
||||
self.assertEqual(middleware_response.set_cookie.call_count, 0)
|
||||
|
||||
def test_middleware_sets_language_cookie_false_already_set(self):
|
||||
"""
|
||||
tests the middleware skips setting the cookie, if its already set correctly
|
||||
"""
|
||||
self.request.user.profile.language = 'en'
|
||||
middleware_response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertFalse = middleware_response.set_cookie.called
|
||||
self.assertEqual(middleware_response.set_cookie.call_count, 0)
|
||||
|
||||
def test_middleware_sets_night_mode_not_set(self):
|
||||
"""
|
||||
tests the middleware will set night_mode if not set
|
||||
"""
|
||||
self.request.session = {}
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.request.session["NIGHT_MODE"], True)
|
||||
|
||||
def test_middleware_sets_night_mode_set(self):
|
||||
"""
|
||||
tests the middleware will set night_mode if set.
|
||||
"""
|
||||
response = self.middleware.process_response(
|
||||
self.request,
|
||||
self.response
|
||||
)
|
||||
self.assertEqual(self.request.session["NIGHT_MODE"], True)
|
||||
94
allianceauth/authentication/tests/test_signals.py
Normal file
94
allianceauth/authentication/tests/test_signals.py
Normal file
@@ -0,0 +1,94 @@
|
||||
from allianceauth.authentication.models import User, UserProfile
|
||||
from allianceauth.eveonline.models import (
|
||||
EveCharacter,
|
||||
EveCorporationInfo,
|
||||
EveAllianceInfo
|
||||
)
|
||||
from django.db.models.signals import (
|
||||
pre_save,
|
||||
post_save,
|
||||
pre_delete,
|
||||
m2m_changed
|
||||
)
|
||||
from allianceauth.tests.auth_utils import AuthUtils
|
||||
|
||||
from django.test.testcases import TestCase
|
||||
from unittest.mock import Mock
|
||||
from . import patch
|
||||
|
||||
|
||||
class TestUserProfileSignals(TestCase):
|
||||
|
||||
def setUp(self):
|
||||
state = AuthUtils.get_member_state()
|
||||
|
||||
self.char = EveCharacter.objects.create(
|
||||
character_id='1234',
|
||||
character_name='test character',
|
||||
corporation_id='2345',
|
||||
corporation_name='test corp',
|
||||
corporation_ticker='tickr',
|
||||
alliance_id='3456',
|
||||
alliance_name='alliance name',
|
||||
)
|
||||
|
||||
self.alliance = EveAllianceInfo.objects.create(
|
||||
alliance_id='3456',
|
||||
alliance_name='alliance name',
|
||||
alliance_ticker='TIKR',
|
||||
executor_corp_id='2345',
|
||||
)
|
||||
|
||||
self.corp = EveCorporationInfo.objects.create(
|
||||
corporation_id='2345',
|
||||
corporation_name='corp name',
|
||||
corporation_ticker='TIKK',
|
||||
member_count=10,
|
||||
alliance=self.alliance,
|
||||
)
|
||||
|
||||
state.member_alliances.add(self.alliance)
|
||||
state.member_corporations.add(self.corp)
|
||||
|
||||
self.member = AuthUtils.create_user('test user')
|
||||
self.member.profile.main_character = self.char
|
||||
self.member.profile.save()
|
||||
|
||||
@patch('.signals.create_required_models')
|
||||
def test_create_required_models_triggered_true(
|
||||
self, create_required_models):
|
||||
"""
|
||||
Create a User object here,
|
||||
to generate UserProfile models
|
||||
"""
|
||||
post_save.connect(create_required_models, sender=User)
|
||||
AuthUtils.create_user('test_create_required_models_triggered')
|
||||
self.assertTrue = create_required_models.called
|
||||
self.assertEqual(create_required_models.call_count, 1)
|
||||
|
||||
user = User.objects.get(username='test_create_required_models_triggered')
|
||||
self.assertIsNot(UserProfile.objects.get(user=user), False)
|
||||
|
||||
@patch('.signals.create_required_models')
|
||||
def test_create_required_models_triggered_false(
|
||||
self, create_required_models):
|
||||
"""
|
||||
Only call a User object Update here,
|
||||
which does not need to generate UserProfile models
|
||||
"""
|
||||
post_save.connect(create_required_models, sender=User)
|
||||
char = EveCharacter.objects.create(
|
||||
character_id='1266',
|
||||
character_name='test character2',
|
||||
corporation_id='2345',
|
||||
corporation_name='test corp',
|
||||
corporation_ticker='tickr',
|
||||
alliance_id='3456',
|
||||
alliance_name='alliance name',
|
||||
)
|
||||
self.member.profile.main_character = char
|
||||
self.member.profile.save()
|
||||
|
||||
self.assertTrue = create_required_models.called
|
||||
self.assertEqual(create_required_models.call_count, 0)
|
||||
self.assertIsNot(UserProfile.objects.get(user=self.member), False)
|
||||
@@ -1,5 +1,4 @@
|
||||
from django.conf.urls import url
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.urls import path
|
||||
from django.views.generic.base import TemplateView
|
||||
|
||||
from . import views
|
||||
@@ -7,21 +6,21 @@ from . import views
|
||||
app_name = 'authentication'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.index, name='index'),
|
||||
url(
|
||||
r'^account/login/$',
|
||||
path('', views.index, name='index'),
|
||||
path(
|
||||
'account/login/',
|
||||
TemplateView.as_view(template_name='public/login.html'),
|
||||
name='login'
|
||||
),
|
||||
url(
|
||||
r'^account/characters/main/$',
|
||||
path(
|
||||
'account/characters/main/',
|
||||
views.main_character_change,
|
||||
name='change_main_character'
|
||||
),
|
||||
url(
|
||||
r'^account/characters/add/$',
|
||||
path(
|
||||
'account/characters/add/',
|
||||
views.add_character,
|
||||
name='add_character'
|
||||
),
|
||||
url(r'^dashboard/$', views.dashboard, name='dashboard'),
|
||||
path('dashboard/', views.dashboard, name='dashboard'),
|
||||
]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.corputils.apps.CorpUtilsConfig'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from allianceauth import hooks
|
||||
from allianceauth.corputils import urls
|
||||
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td class="text-center col-lg-6{% if corpstats.corp.alliance %}{% else %}col-lg-offset-3{% endif %}">
|
||||
<img class="ra-avatar" src="{{ corpstats.corp.logo_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ corpstats.corp.logo_url_64 }}" alt="{{ corpstats.corp.corporation_name }}">
|
||||
</td>
|
||||
{% if corpstats.corp.alliance %}
|
||||
<td class="text-center col-lg-6">
|
||||
<img class="ra-avatar" src="{{ corpstats.corp.alliance.logo_url_64 }}">
|
||||
<img class="ra-avatar" src="{{ corpstats.corp.alliance.logo_url_64 }}" alt="{{ corpstats.corp.alliance.alliance_name }}">
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
@@ -59,7 +59,7 @@
|
||||
<tr>
|
||||
<td class="text-center" style="vertical-align:middle">
|
||||
<div class="thumbnail" style="border: 0 none; box-shadow: none; background: transparent;">
|
||||
<img src="{{ main.main.portrait_url_64 }}" class="img-circle">
|
||||
<img src="{{ main.main.portrait_url_64 }}" class="img-circle" alt="{{ main.main }}">
|
||||
<div class="caption text-center">
|
||||
{{ main.main }}
|
||||
</div>
|
||||
@@ -80,7 +80,7 @@
|
||||
<tr>
|
||||
<td class="text-center" style="width:5%">
|
||||
<div class="thumbnail" style="border: 0 none; box-shadow: none; background: transparent;">
|
||||
<img src="{{ alt.portrait_url_32 }}" class="img-circle">
|
||||
<img src="{{ alt.portrait_url_32 }}" class="img-circle" alt="{{ alt.character_name }}">
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-center" style="width:30%">{{ alt.character_name }}</td>
|
||||
@@ -119,7 +119,7 @@
|
||||
<tbody>
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle"></td>
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle" alt="{{ member }}"></td>
|
||||
<td class="text-center">{{ member }}</td>
|
||||
<td class="text-center">
|
||||
<a href="https://zkillboard.com/character/{{ member.character_id }}/" class="label label-danger" target="_blank">{% translate "Killboard" %}</a>
|
||||
@@ -131,7 +131,7 @@
|
||||
{% endfor %}
|
||||
{% for member in unregistered %}
|
||||
<tr class="danger">
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle"></td>
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle" alt="{{ member.character_name }}"></td>
|
||||
<td class="text-center">{{ member.character_name }}</td>
|
||||
<td class="text-center">
|
||||
<a href="https://zkillboard.com/character/{{ member.character_id }}/" class="label label-danger" target="_blank">{% translate "Killboard" %}</a>
|
||||
@@ -160,7 +160,7 @@
|
||||
<tbody>
|
||||
{% for member in unregistered %}
|
||||
<tr class="danger">
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle"></td>
|
||||
<td><img src="{{ member.portrait_url }}" class="img-circle" alt="{{ member.character_name }}"></td>
|
||||
<td class="text-center">{{ member.character_name }}</td>
|
||||
<td class="text-center">
|
||||
<a href="https://zkillboard.com/character/{{ member.character_id }}/" class="label label-danger" target="_blank">
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<tbody>
|
||||
{% for result in results %}
|
||||
<tr {% if not result.1.registered %}class="danger"{% endif %}>
|
||||
<td class="text-center"><img src="{{ result.1.portrait_url }}" class="img-circle"></td>
|
||||
<td class="text-center"><img src="{{ result.1.portrait_url }}" class="img-circle" alt="{{ result.1.character_name }}"></td>
|
||||
<td class="text-center">{{ result.1.character_name }}</td>
|
||||
<td class="text-center">{{ result.0.corp.corporation_name }}</td>
|
||||
<td class="text-center"><a href="https://zkillboard.com/character/{{ result.1.character_id }}/" class="label label-danger" target="_blank">{% translate "Killboard" %}</a></td>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
from django.conf.urls import url
|
||||
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
app_name = 'corputils'
|
||||
urlpatterns = [
|
||||
url(r'^$', views.corpstats_view, name='view'),
|
||||
url(r'^add/$', views.corpstats_add, name='add'),
|
||||
url(r'^(?P<corp_id>(\d)*)/$', views.corpstats_view, name='view_corp'),
|
||||
url(r'^(?P<corp_id>(\d)+)/update/$', views.corpstats_update, name='update'),
|
||||
url(r'^search/$', views.corpstats_search, name='search'),
|
||||
]
|
||||
path('', views.corpstats_view, name='view'),
|
||||
path('add/', views.corpstats_add, name='add'),
|
||||
path('<int:corp_id>/', views.corpstats_view, name='view_corp'),
|
||||
path('<int:corp_id>/update/', views.corpstats_update, name='update'),
|
||||
path('search/', views.corpstats_search, name='search'),
|
||||
]
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import login_required, permission_required,
|
||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||
from django.db import IntegrityError
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from esi.decorators import token_required
|
||||
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.eveonline.apps.EveonlineConfig'
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.eveonline.autogroups.apps.EveAutogroupsConfig'
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.2.10 on 2022-01-05 18:44
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('eveonline', '0015_factions'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='evecharacter',
|
||||
name='character_name',
|
||||
field=models.CharField(db_index=True, max_length=254),
|
||||
),
|
||||
]
|
||||
@@ -25,6 +25,8 @@ DOOMHEIM_CORPORATION_ID = 1000001
|
||||
|
||||
|
||||
class EveFactionInfo(models.Model):
|
||||
"""A faction in Eve Online."""
|
||||
|
||||
faction_id = models.PositiveIntegerField(unique=True, db_index=True)
|
||||
faction_name = models.CharField(max_length=254, unique=True)
|
||||
|
||||
@@ -66,6 +68,8 @@ class EveFactionInfo(models.Model):
|
||||
|
||||
|
||||
class EveAllianceInfo(models.Model):
|
||||
"""An alliance in Eve Online."""
|
||||
|
||||
alliance_id = models.PositiveIntegerField(unique=True)
|
||||
alliance_name = models.CharField(max_length=254, unique=True)
|
||||
alliance_ticker = models.CharField(max_length=254)
|
||||
@@ -132,6 +136,8 @@ class EveAllianceInfo(models.Model):
|
||||
|
||||
|
||||
class EveCorporationInfo(models.Model):
|
||||
"""A corporation in Eve Online."""
|
||||
|
||||
corporation_id = models.PositiveIntegerField(unique=True)
|
||||
corporation_name = models.CharField(max_length=254, unique=True)
|
||||
corporation_ticker = models.CharField(max_length=254)
|
||||
@@ -195,9 +201,10 @@ class EveCorporationInfo(models.Model):
|
||||
|
||||
|
||||
class EveCharacter(models.Model):
|
||||
"""Character in Eve Online"""
|
||||
"""A character in Eve Online."""
|
||||
|
||||
character_id = models.PositiveIntegerField(unique=True)
|
||||
character_name = models.CharField(max_length=254, unique=True)
|
||||
character_name = models.CharField(max_length=254, db_index=True)
|
||||
corporation_id = models.PositiveIntegerField()
|
||||
corporation_name = models.CharField(max_length=254)
|
||||
corporation_ticker = models.CharField(max_length=5)
|
||||
|
||||
@@ -40,7 +40,7 @@ def update_character(character_id: int) -> None:
|
||||
def run_model_update():
|
||||
"""Update all alliances, corporations and characters from ESI"""
|
||||
|
||||
# update existing corp models
|
||||
#update existing corp models
|
||||
for corp in EveCorporationInfo.objects.all().values('corporation_id'):
|
||||
update_corp.apply_async(args=[corp['corporation_id']], priority=TASK_PRIORITY)
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.fleetactivitytracking.apps.FatConfig'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from . import urls
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from allianceauth import hooks
|
||||
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class FatlinkForm(forms.Form):
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<div class="panel-heading">{{ character_name }}</div>
|
||||
<div class="panel-body">
|
||||
<div class="col-lg-2 col-sm-2">
|
||||
<img class="ra-avatar img-responsive" src="{{ character_portrait_url }}">
|
||||
<img class="ra-avatar img-responsive" src="{{ character_portrait_url }}" alt="{{ character_name }}">
|
||||
</div>
|
||||
<div class="col-lg-10 col-sm-2">
|
||||
<div class="alert alert-danger" role="alert">{% translate "Character not registered!" %}</div>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Create Fatlink" %}{% endblock page_title %}
|
||||
@@ -21,7 +20,7 @@
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit" name="submit_fat">{% translate "Create fatlink" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% block page_title %}{% translate "Fatlink view" %}{% endblock page_title %}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Personal fatlink statistics" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Personal fatlink statistics" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Fatlink Corp Statistics" %}{% endblock page_title %}
|
||||
@@ -29,7 +27,7 @@
|
||||
{% for memberStat in fatStats %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ memberStat.mainchar.portrait_url_32 }}" class="ra-avatar img-responsive">
|
||||
<img src="{{ memberStat.mainchar.portrait_url_32 }}" class="ra-avatar img-responsive" alt="{{ memberStat.mainchar.character_name }}">
|
||||
</td>
|
||||
<td class="text-center">{{ memberStat.mainchar.character_name }}</td>
|
||||
<td class="text-center">{{ memberStat.n_chars }}</td>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Fatlink statistics" %}{% endblock page_title %}
|
||||
@@ -30,9 +28,9 @@
|
||||
{% for corpStat in fatStats %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ corpStat.corp.logo_url_32 }}" class="ra-avatar img-responsive">
|
||||
<img src="{{ corpStat.corp.logo_url_32 }}" class="ra-avatar img-responsive" alt="{{ corpStat.corp.corporation_name }}">
|
||||
</td>
|
||||
<td class="text-center"><a href="{% url 'fatlink:statistics_corp' corpStat.corp.corporation_id %}">[{{ corpStat.corp.corporation_ticker }}]</td>
|
||||
<td class="text-center"><a href="{% url 'fatlink:statistics_corp' corpStat.corp.corporation_id %}">[{{ corpStat.corp.corporation_ticker }}]</a></td>
|
||||
<td class="text-center">{{ corpStat.corp.corporation_name }}</td>
|
||||
<td class="text-center">{{ corpStat.corp.member_count }}</td>
|
||||
<td class="text-center">{{ corpStat.n_fats }}</td>
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Fatlink view" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,30 +1,30 @@
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
app_name = 'fleetactivitytracking'
|
||||
|
||||
urlpatterns = [
|
||||
# FleetActivityTracking (FAT)
|
||||
url(r'^$', views.fatlink_view, name='view'),
|
||||
url(r'^statistics/$', views.fatlink_statistics_view, name='statistics'),
|
||||
url(r'^statistics/corp/(\w+)$', views.fatlink_statistics_corp_view,
|
||||
path('', views.fatlink_view, name='view'),
|
||||
path('statistics/', views.fatlink_statistics_view, name='statistics'),
|
||||
path('statistics/corp/<int:corpid>/', views.fatlink_statistics_corp_view,
|
||||
name='statistics_corp'),
|
||||
url(r'^statistics/corp/(?P<corpid>\w+)/(?P<year>[0-9]+)/(?P<month>[0-9]+)/',
|
||||
path('statistics/corp/<int:corpid>/<int:year>/<int:month>/',
|
||||
views.fatlink_statistics_corp_view,
|
||||
name='statistics_corp_month'),
|
||||
url(r'^statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$', views.fatlink_statistics_view,
|
||||
path('statistics/<int:year>/<int:month>/', views.fatlink_statistics_view,
|
||||
name='statistics_month'),
|
||||
url(r'^user/statistics/$', views.fatlink_personal_statistics_view,
|
||||
path('user/statistics/', views.fatlink_personal_statistics_view,
|
||||
name='personal_statistics'),
|
||||
url(r'^user/statistics/(?P<year>[0-9]+)/$', views.fatlink_personal_statistics_view,
|
||||
path('user/statistics/<int:year>/', views.fatlink_personal_statistics_view,
|
||||
name='personal_statistics_year'),
|
||||
url(r'^user/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
path('user/statistics/<int:year>/<int:month>/',
|
||||
views.fatlink_monthly_personal_statistics_view,
|
||||
name='personal_statistics_month'),
|
||||
url(r'^user/(?P<char_id>[0-9]+)/statistics/(?P<year>[0-9]+)/(?P<month>[0-9]+)/$',
|
||||
path('user/<int:char_id>/statistics/<int:year>/<int:month>/',
|
||||
views.fatlink_monthly_personal_statistics_view,
|
||||
name='user_statistics_month'),
|
||||
url(r'^create/$', views.create_fatlink_view, name='create'),
|
||||
url(r'^modify/(?P<fat_hash>[a-zA-Z0-9_-]+)/$', views.modify_fatlink_view, name='modify'),
|
||||
url(r'^link/(?P<fat_hash>[a-zA-Z0-9]+)/$', views.click_fatlink_view, name='click'),
|
||||
path('create/', views.create_fatlink_view, name='create'),
|
||||
path('modify/<str:fat_hash>/', views.modify_fatlink_view, name='modify'),
|
||||
path('link/<str:fat_hash>/', views.click_fatlink_view, name='click'),
|
||||
]
|
||||
|
||||
@@ -10,7 +10,7 @@ from django.contrib.auth.models import User
|
||||
from django.core.exceptions import ValidationError, ObjectDoesNotExist
|
||||
from django.shortcuts import render, redirect, get_object_or_404, Http404
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from esi.decorators import token_required
|
||||
from allianceauth.eveonline.providers import provider
|
||||
from .forms import FatlinkForm
|
||||
@@ -212,7 +212,14 @@ def fatlink_monthly_personal_statistics_view(request, year, month, char_id=None)
|
||||
start_of_previous_month = first_day_of_previous_month(year, month)
|
||||
|
||||
if request.user.has_perm('auth.fleetactivitytracking_statistics') and char_id:
|
||||
user = EveCharacter.objects.get(character_id=char_id).user
|
||||
try:
|
||||
user = EveCharacter.objects.get(character_id=char_id).character_ownership.user
|
||||
except EveCharacter.DoesNotExist:
|
||||
messages.error(request, _('Character does not exist'))
|
||||
return redirect('fatlink:view')
|
||||
except AttributeError:
|
||||
messages.error(request, _('User does not exist'))
|
||||
return redirect('fatlink:view')
|
||||
else:
|
||||
user = request.user
|
||||
logger.debug(f"Personal monthly statistics view for user {user} called by {request.user}")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.groupmanagement.apps.GroupManagementConfig'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
from django.apps import apps
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.models import Group as BaseGroup
|
||||
from django.contrib.auth.models import Permission, User
|
||||
from django.db.models import Count
|
||||
|
||||
from django.contrib.auth.models import Group as BaseGroup, Permission, User
|
||||
from django.db.models import Count, Exists, OuterRef
|
||||
from django.db.models.functions import Lower
|
||||
from django.db.models.signals import (
|
||||
m2m_changed,
|
||||
@@ -15,6 +15,7 @@ from django.dispatch import receiver
|
||||
|
||||
from .forms import GroupAdminForm, ReservedGroupNameAdminForm
|
||||
from .models import AuthGroup, GroupRequest, ReservedGroupName
|
||||
from .tasks import remove_users_not_matching_states_from_group
|
||||
|
||||
if 'eve_autogroups' in apps.app_configs:
|
||||
_has_auto_groups = True
|
||||
@@ -106,14 +107,13 @@ class HasLeaderFilter(admin.SimpleListFilter):
|
||||
|
||||
class GroupAdmin(admin.ModelAdmin):
|
||||
form = GroupAdminForm
|
||||
list_select_related = ('authgroup',)
|
||||
ordering = ('name',)
|
||||
list_display = (
|
||||
'name',
|
||||
'_description',
|
||||
'_properties',
|
||||
'_member_count',
|
||||
'has_leader'
|
||||
'has_leader',
|
||||
)
|
||||
list_filter = [
|
||||
'authgroup__internal',
|
||||
@@ -129,31 +129,51 @@ class GroupAdmin(admin.ModelAdmin):
|
||||
|
||||
def get_queryset(self, request):
|
||||
qs = super().get_queryset(request)
|
||||
if _has_auto_groups:
|
||||
qs = qs.prefetch_related('managedalliancegroup_set', 'managedcorpgroup_set')
|
||||
qs = qs.prefetch_related('authgroup__group_leaders').select_related('authgroup')
|
||||
qs = qs.annotate(
|
||||
member_count=Count('user', distinct=True),
|
||||
has_leader_qs = (
|
||||
AuthGroup.objects.filter(group=OuterRef('pk'), group_leaders__isnull=False)
|
||||
)
|
||||
has_leader_groups_qs = (
|
||||
AuthGroup.objects.filter(
|
||||
group=OuterRef('pk'), group_leader_groups__isnull=False
|
||||
)
|
||||
)
|
||||
qs = (
|
||||
qs.select_related('authgroup')
|
||||
.annotate(member_count=Count('user', distinct=True))
|
||||
.annotate(has_leader=Exists(has_leader_qs))
|
||||
.annotate(has_leader_groups=Exists(has_leader_groups_qs))
|
||||
)
|
||||
if _has_auto_groups:
|
||||
is_autogroup_corp = (
|
||||
Group.objects.filter(
|
||||
pk=OuterRef('pk'), managedcorpgroup__isnull=False
|
||||
)
|
||||
)
|
||||
is_autogroup_alliance = (
|
||||
Group.objects.filter(
|
||||
pk=OuterRef('pk'), managedalliancegroup__isnull=False
|
||||
)
|
||||
)
|
||||
qs = (
|
||||
qs.annotate(is_autogroup_corp=Exists(is_autogroup_corp))
|
||||
.annotate(is_autogroup_alliance=Exists(is_autogroup_alliance))
|
||||
)
|
||||
return qs
|
||||
|
||||
def _description(self, obj):
|
||||
return obj.authgroup.description
|
||||
|
||||
@admin.display(description="Members", ordering="member_count")
|
||||
@admin.display(description='Members', ordering='member_count')
|
||||
def _member_count(self, obj):
|
||||
return obj.member_count
|
||||
|
||||
@admin.display(boolean=True)
|
||||
def has_leader(self, obj):
|
||||
return obj.authgroup.group_leaders.exists() or obj.authgroup.group_leader_groups.exists()
|
||||
return obj.has_leader or obj.has_leader_groups
|
||||
|
||||
def _properties(self, obj):
|
||||
properties = list()
|
||||
if _has_auto_groups and (
|
||||
obj.managedalliancegroup_set.exists()
|
||||
or obj.managedcorpgroup_set.exists()
|
||||
):
|
||||
if _has_auto_groups and (obj.is_autogroup_corp or obj.is_autogroup_alliance):
|
||||
properties.append('Auto Group')
|
||||
elif obj.authgroup.internal:
|
||||
properties.append('Internal')
|
||||
@@ -183,6 +203,8 @@ class GroupAdmin(admin.ModelAdmin):
|
||||
ag_instance = inline_form.save(commit=False)
|
||||
ag_instance.group = form.instance
|
||||
ag_instance.save()
|
||||
if ag_instance.states.exists():
|
||||
remove_users_not_matching_states_from_group.delay(ag_instance.group.pk)
|
||||
formset.save()
|
||||
|
||||
def get_readonly_fields(self, request, obj=None):
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
||||
from allianceauth import hooks
|
||||
|
||||
@@ -189,6 +189,15 @@ class AuthGroup(models.Model):
|
||||
| User.objects.filter(groups__in=list(self.group_leader_groups.all()))
|
||||
)
|
||||
|
||||
def remove_users_not_matching_states(self):
|
||||
"""Remove users not matching defined states from related group."""
|
||||
states_qs = self.states.all()
|
||||
if states_qs.exists():
|
||||
states = list(states_qs)
|
||||
non_compliant_users = self.group.user_set.exclude(profile__state__in=states)
|
||||
for user in non_compliant_users:
|
||||
self.group.user_set.remove(user)
|
||||
|
||||
|
||||
class ReservedGroupName(models.Model):
|
||||
"""Name that can not be used for groups.
|
||||
|
||||
10
allianceauth/groupmanagement/tasks.py
Normal file
10
allianceauth/groupmanagement/tasks.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from celery import shared_task
|
||||
|
||||
from django.contrib.auth.models import Group
|
||||
|
||||
|
||||
@shared_task
|
||||
def remove_users_not_matching_states_from_group(group_pk: int) -> None:
|
||||
"""Remove users not matching defined states from related group."""
|
||||
group = Group.objects.get(pk=group_pk)
|
||||
group.authgroup.remove_users_not_matching_states()
|
||||
@@ -25,13 +25,15 @@
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped" id="log-entries">
|
||||
<thead>
|
||||
<th scope="col">{% translate "Date/Time" %}</th>
|
||||
<th scope="col">{% translate "Requestor" %}</th>
|
||||
<th scope="col">{% translate "Character" %}</th>
|
||||
<th scope="col">{% translate "Corporation" %}</th>
|
||||
<th scope="col">{% translate "Type" %}</th>
|
||||
<th scope="col">{% translate "Action" %}</th>
|
||||
<th scope="col">{% translate "Actor" %}</th>
|
||||
<tr>
|
||||
<th scope="col">{% translate "Date/Time" %}</th>
|
||||
<th scope="col">{% translate "Requestor" %}</th>
|
||||
<th scope="col">{% translate "Character" %}</th>
|
||||
<th scope="col">{% translate "Corporation" %}</th>
|
||||
<th scope="col">{% translate "Type" %}</th>
|
||||
<th scope="col">{% translate "Action" %}</th>
|
||||
<th scope="col">{% translate "Actor" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
@@ -74,7 +76,7 @@
|
||||
{% block extra_javascript %}
|
||||
{% include 'bundles/datatables-js.html' %}
|
||||
{% include 'bundles/moment-js.html' with locale=True %}
|
||||
<script type="application/javascript" src="{% static 'js/filterDropDown/filterDropDown.min.js' %}"></script>
|
||||
{% include 'bundles/filterdropdown-js.html' %}
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load evelinks %}
|
||||
|
||||
@@ -37,7 +36,7 @@
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ member.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;">
|
||||
<img src="{{ member.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;" alt="{{ member.main_char.character_name }}">
|
||||
{% if member.main_char %}
|
||||
<a href="{{ member.main_char|evewho_character_url }}" target="_blank">
|
||||
{{ member.main_char.character_name }}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Groups Membership" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Available Groups" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load evelinks %}
|
||||
|
||||
@@ -64,7 +63,7 @@
|
||||
{% for acceptrequest in acceptrequests %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ acceptrequest.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;">
|
||||
<img src="{{ acceptrequest.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;" alt="{{ acceptrequest.main_char.character_name }}">
|
||||
{% if acceptrequest.main_char %}
|
||||
<a href="{{ acceptrequest.main_char|evewho_character_url }}" target="_blank">
|
||||
{{ acceptrequest.main_char.character_name }}
|
||||
@@ -121,7 +120,7 @@
|
||||
{% for leaverequest in leaverequests %}
|
||||
<tr>
|
||||
<td>
|
||||
<img src="{{ leaverequest.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;">
|
||||
<img src="{{ leaverequest.main_char|character_portrait_url:32 }}" class="img-circle" style="margin-right: 1rem;" alt="{{ leaverequest.main_char.character_name }}">
|
||||
{% if leaverequest.main_char %}
|
||||
<a href="{{ leaverequest.main_char|evewho_character_url }}" target="_blank">
|
||||
{{ leaverequest.main_char.character_name }}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% load navactive %}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from django.contrib.admin.sites import AdminSite
|
||||
from django.contrib.auth.models import User
|
||||
from django.test import TestCase, RequestFactory, Client
|
||||
from django.test import TestCase, RequestFactory, Client, override_settings
|
||||
|
||||
from allianceauth.authentication.models import CharacterOwnership, State
|
||||
from allianceauth.eveonline.models import (
|
||||
@@ -236,60 +236,104 @@ class TestGroupAdmin(TestCase):
|
||||
self.assertEqual(result, expected)
|
||||
|
||||
def test_member_count(self):
|
||||
expected = 1
|
||||
obj = self.modeladmin.get_queryset(MockRequest(user=self.user_1))\
|
||||
.get(pk=self.group_1.pk)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_1.pk)
|
||||
# when
|
||||
result = self.modeladmin._member_count(obj)
|
||||
self.assertEqual(result, expected)
|
||||
# then
|
||||
self.assertEqual(result, 1)
|
||||
|
||||
def test_has_leader_user(self):
|
||||
result = self.modeladmin.has_leader(self.group_1)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_1.pk)
|
||||
# when
|
||||
result = self.modeladmin.has_leader(obj)
|
||||
# then
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_has_leader_group(self):
|
||||
result = self.modeladmin.has_leader(self.group_2)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_2.pk)
|
||||
# when
|
||||
result = self.modeladmin.has_leader(obj)
|
||||
# then
|
||||
self.assertTrue(result)
|
||||
|
||||
def test_properties_1(self):
|
||||
expected = ['Default']
|
||||
result = self.modeladmin._properties(self.group_1)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_1.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Default'])
|
||||
|
||||
def test_properties_2(self):
|
||||
expected = ['Internal']
|
||||
result = self.modeladmin._properties(self.group_2)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_2.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Internal'])
|
||||
|
||||
def test_properties_3(self):
|
||||
expected = ['Hidden']
|
||||
result = self.modeladmin._properties(self.group_3)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_3.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Hidden'])
|
||||
|
||||
def test_properties_4(self):
|
||||
expected = ['Open']
|
||||
result = self.modeladmin._properties(self.group_4)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_4.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Open'])
|
||||
|
||||
def test_properties_5(self):
|
||||
expected = ['Public']
|
||||
result = self.modeladmin._properties(self.group_5)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_5.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Public'])
|
||||
|
||||
def test_properties_6(self):
|
||||
expected = ['Hidden', 'Open', 'Public']
|
||||
result = self.modeladmin._properties(self.group_6)
|
||||
self.assertListEqual(result, expected)
|
||||
# given
|
||||
request = MockRequest(user=self.user_1)
|
||||
obj = self.modeladmin.get_queryset(request).get(pk=self.group_6.pk)
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
self.assertListEqual(result, ['Hidden', 'Open', 'Public'])
|
||||
|
||||
if _has_auto_groups:
|
||||
@patch(MODULE_PATH + '._has_auto_groups', True)
|
||||
def test_properties_7(self):
|
||||
def test_should_show_autogroup_for_corporation(self):
|
||||
# given
|
||||
self._create_autogroups()
|
||||
expected = ['Auto Group']
|
||||
my_group = Group.objects\
|
||||
.filter(managedcorpgroup__isnull=False)\
|
||||
.first()
|
||||
result = self.modeladmin._properties(my_group)
|
||||
self.assertListEqual(result, expected)
|
||||
request = MockRequest(user=self.user_1)
|
||||
queryset = self.modeladmin.get_queryset(request)
|
||||
obj = queryset.filter(managedcorpgroup__isnull=False).first()
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
# then
|
||||
self.assertListEqual(result, ['Auto Group'])
|
||||
|
||||
@patch(MODULE_PATH + '._has_auto_groups', True)
|
||||
def test_should_show_autogroup_for_alliance(self):
|
||||
# given
|
||||
self._create_autogroups()
|
||||
request = MockRequest(user=self.user_1)
|
||||
queryset = self.modeladmin.get_queryset(request)
|
||||
obj = queryset.filter(managedalliancegroup__isnull=False).first()
|
||||
# when
|
||||
result = self.modeladmin._properties(obj)
|
||||
# then
|
||||
self.assertListEqual(result, ['Auto Group'])
|
||||
|
||||
# actions
|
||||
|
||||
@@ -539,6 +583,68 @@ class TestGroupAdminChangeFormSuperuserExclusiveEdits(WebTest):
|
||||
self.assertNotIn(field, form.fields)
|
||||
|
||||
|
||||
@override_settings(CELERY_ALWAYS_EAGER=True, CELERY_EAGER_PROPAGATES_EXCEPTIONS=True)
|
||||
class TestGroupAdmin2(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super().setUpClass()
|
||||
cls.superuser = User.objects.create_superuser("super")
|
||||
|
||||
def test_should_remove_users_from_state_groups(self):
|
||||
# given
|
||||
user_member = AuthUtils.create_user("Bruce Wayne")
|
||||
character_member = AuthUtils.add_main_character_2(
|
||||
user_member,
|
||||
name="Bruce Wayne",
|
||||
character_id=1001,
|
||||
corp_id=2001,
|
||||
corp_name="Wayne Technologies",
|
||||
)
|
||||
user_guest = AuthUtils.create_user("Lex Luthor")
|
||||
AuthUtils.add_main_character_2(
|
||||
user_guest,
|
||||
name="Lex Luthor",
|
||||
character_id=1011,
|
||||
corp_id=2011,
|
||||
corp_name="Luthor Corp",
|
||||
)
|
||||
member_state = AuthUtils.get_member_state()
|
||||
member_state.member_characters.add(character_member)
|
||||
user_member.refresh_from_db()
|
||||
user_guest.refresh_from_db()
|
||||
group = Group.objects.create(name="dummy")
|
||||
user_member.groups.add(group)
|
||||
user_guest.groups.add(group)
|
||||
group.authgroup.states.add(member_state)
|
||||
self.client.force_login(self.superuser)
|
||||
# when
|
||||
response = self.client.post(
|
||||
f"/admin/groupmanagement/group/{group.pk}/change/",
|
||||
data={
|
||||
"name": f"{group.name}",
|
||||
"authgroup-TOTAL_FORMS": "1",
|
||||
"authgroup-INITIAL_FORMS": "1",
|
||||
"authgroup-MIN_NUM_FORMS": "0",
|
||||
"authgroup-MAX_NUM_FORMS": "1",
|
||||
"authgroup-0-description": "",
|
||||
"authgroup-0-states": f"{member_state.pk}",
|
||||
"authgroup-0-internal": "on",
|
||||
"authgroup-0-hidden": "on",
|
||||
"authgroup-0-group": f"{group.pk}",
|
||||
"authgroup-__prefix__-description": "",
|
||||
"authgroup-__prefix__-internal": "on",
|
||||
"authgroup-__prefix__-hidden": "on",
|
||||
"authgroup-__prefix__-group": f"{group.pk}",
|
||||
"_save": "Save"
|
||||
}
|
||||
)
|
||||
# then
|
||||
self.assertEqual(response.status_code, 302)
|
||||
self.assertEqual(response.url, "/admin/groupmanagement/group/")
|
||||
self.assertIn(group, user_member.groups.all())
|
||||
self.assertNotIn(group, user_guest.groups.all())
|
||||
|
||||
|
||||
class TestReservedGroupNameAdmin(TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
|
||||
@@ -232,6 +232,38 @@ class TestAuthGroup(TestCase):
|
||||
expected = 'Superheros'
|
||||
self.assertEqual(str(group.authgroup), expected)
|
||||
|
||||
def test_should_remove_guests_from_group_when_restricted_to_members_only(self):
|
||||
# given
|
||||
user_member = AuthUtils.create_user("Bruce Wayne")
|
||||
character_member = AuthUtils.add_main_character_2(
|
||||
user_member,
|
||||
name="Bruce Wayne",
|
||||
character_id=1001,
|
||||
corp_id=2001,
|
||||
corp_name="Wayne Technologies",
|
||||
)
|
||||
user_guest = AuthUtils.create_user("Lex Luthor")
|
||||
AuthUtils.add_main_character_2(
|
||||
user_guest,
|
||||
name="Lex Luthor",
|
||||
character_id=1011,
|
||||
corp_id=2011,
|
||||
corp_name="Luthor Corp",
|
||||
)
|
||||
member_state = AuthUtils.get_member_state()
|
||||
member_state.member_characters.add(character_member)
|
||||
user_member.refresh_from_db()
|
||||
user_guest.refresh_from_db()
|
||||
group = Group.objects.create(name="dummy")
|
||||
user_member.groups.add(group)
|
||||
user_guest.groups.add(group)
|
||||
group.authgroup.states.add(member_state)
|
||||
# when
|
||||
group.authgroup.remove_users_not_matching_states()
|
||||
# then
|
||||
self.assertIn(group, user_member.groups.all())
|
||||
self.assertNotIn(group, user_guest.groups.all())
|
||||
|
||||
|
||||
class TestAuthGroupRequestApprovers(TestCase):
|
||||
def setUp(self) -> None:
|
||||
|
||||
@@ -1,51 +1,50 @@
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
from django.conf.urls import url
|
||||
|
||||
app_name = "groupmanagement"
|
||||
|
||||
urlpatterns = [
|
||||
# groups
|
||||
url(r"^groups/$", views.groups_view, name="groups"),
|
||||
url(r"^group/request/join/(\w+)/$", views.group_request_add, name="request_add"),
|
||||
url(
|
||||
r"^group/request/leave/(\w+)/$", views.group_request_leave, name="request_leave"
|
||||
path("groups", views.groups_view, name="groups"),
|
||||
path("group/request/join/<int:group_id>/", views.group_request_add, name="request_add"),
|
||||
path(
|
||||
"group/request/leave/<int:group_id>/", views.group_request_leave, name="request_leave"
|
||||
),
|
||||
# group management
|
||||
url(r"^groupmanagement/requests/$", views.group_management, name="management"),
|
||||
url(r"^groupmanagement/membership/$", views.group_membership, name="membership"),
|
||||
url(
|
||||
r"^groupmanagement/membership/(\w+)/$",
|
||||
path("groupmanagement/requests/", views.group_management, name="management"),
|
||||
path("groupmanagement/membership/", views.group_membership, name="membership"),
|
||||
path(
|
||||
"groupmanagement/membership/<int:group_id>/",
|
||||
views.group_membership_list,
|
||||
name="membership",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/membership/(\w+)/audit-log/$",
|
||||
path(
|
||||
"groupmanagement/membership/<int:group_id>/audit-log/",
|
||||
views.group_membership_audit,
|
||||
name="audit_log",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/membership/(\w+)/remove/(\w+)/$",
|
||||
path(
|
||||
"groupmanagement/membership/<int:group_id>/remove/<int:user_id>/",
|
||||
views.group_membership_remove,
|
||||
name="membership_remove",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/request/join/accept/(\w+)/$",
|
||||
path(
|
||||
"groupmanagement/request/join/accept/<int:group_request_id>/",
|
||||
views.group_accept_request,
|
||||
name="accept_request",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/request/join/reject/(\w+)/$",
|
||||
path(
|
||||
"groupmanagement/request/join/reject/<int:group_request_id>/",
|
||||
views.group_reject_request,
|
||||
name="reject_request",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/request/leave/accept/(\w+)/$",
|
||||
path(
|
||||
"groupmanagement/request/leave/accept/<int:group_request_id>/",
|
||||
views.group_leave_accept_request,
|
||||
name="leave_accept_request",
|
||||
),
|
||||
url(
|
||||
r"^groupmanagement/request/leave/reject/(\w+)/$",
|
||||
path(
|
||||
"groupmanagement/request/leave/reject/<int:group_request_id>/",
|
||||
views.group_leave_reject_request,
|
||||
name="leave_reject_request",
|
||||
),
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.core.exceptions import ObjectDoesNotExist, PermissionDenied
|
||||
from django.db.models import Count
|
||||
from django.http import Http404
|
||||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from allianceauth.notifications import notify
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.hrapplications.apps.HRApplicationsConfig'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from allianceauth import hooks
|
||||
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class HRApplicationCommentForm(forms.Form):
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Choose a Corp" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Apply To" %} {{ corp.corporation_name }}{% endblock page_title %}
|
||||
@@ -16,11 +15,11 @@
|
||||
<label class="control-label" for="id_{{ question.pk }}">{{ question.title }}</label>
|
||||
<div class=" ">
|
||||
{% if question.help_text %}
|
||||
<div cass="text-center">{{ question.help_text }}</div>
|
||||
<div class="text-center">{{ question.help_text }}</div>
|
||||
{% endif %}
|
||||
{% for choice in question.choices.all %}
|
||||
<input type={% if question.multi_select == False %}"radio"{% else %}"checkbox"{% endif %} name="{{ question.pk }}" id="id_{{ question.pk }}" value="{{ choice.choice_text }}" />
|
||||
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
|
||||
<input type={% if question.multi_select == False %}"radio"{% else %}"checkbox"{% endif %} name="{{ question.pk }}" id="id_{{ question.pk }}_choice_{{ forloop.counter }}" value="{{ choice.choice_text }}">
|
||||
<label for="id_{{ question.pk }}_choice_{{ forloop.counter }}">{{ choice.choice_text }}</label><br>
|
||||
{% empty %}
|
||||
<textarea class="form-control" cols="30" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="4"></textarea>
|
||||
{% endfor %}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "HR Application Management" %}{% endblock page_title %}
|
||||
@@ -178,10 +177,10 @@
|
||||
<h4 class="modal-title" id="myModalLabel">{% translate "Application Search" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form" action={% url 'hrapplications:search' %} method="POST">
|
||||
<form class="form-signin" role="form" action="{% url 'hrapplications:search' %}" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ search_form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Search" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "HR Application Management" %}{% endblock page_title %}
|
||||
@@ -64,10 +63,10 @@
|
||||
<h4 class="modal-title" id="myModalLabel">{% translate "Application Search" %}</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form class="form-signin" role="form" action={% url 'hrapplications:search' %} method="POST">
|
||||
<form class="form-signin" role="form" action="{% url 'hrapplications:search' %}" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ search_form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Search" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load bootstrap %}
|
||||
{% load i18n %}
|
||||
|
||||
@@ -49,7 +48,7 @@
|
||||
{% for char in app.characters %}
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<img class="ra-avatar img-responsive img-circle" src="{{ char.portrait_url_32 }}">
|
||||
<img class="ra-avatar img-responsive img-circle" src="{{ char.portrait_url_32 }}" alt="{{ char.character_name }}">
|
||||
</td>
|
||||
<td class="text-center">{{ char.character_name }}</td>
|
||||
<td class="text-center">{{ char.corporation_name }}</td>
|
||||
@@ -140,7 +139,7 @@
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ comment_form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Add Comment" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,31 +1,31 @@
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'hrapplications'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.hr_application_management_view,
|
||||
path('', views.hr_application_management_view,
|
||||
name="index"),
|
||||
url(r'^create/$', views.hr_application_create_view,
|
||||
path('create/', views.hr_application_create_view,
|
||||
name="create_view"),
|
||||
url(r'^create/(\d+)', views.hr_application_create_view,
|
||||
path('create/<int:form_id>/', views.hr_application_create_view,
|
||||
name="create_view"),
|
||||
url(r'^remove/(\w+)', views.hr_application_remove,
|
||||
path('remove/<int:app_id>/', views.hr_application_remove,
|
||||
name="remove"),
|
||||
url(r'^view/(\w+)', views.hr_application_view,
|
||||
path('view/<int:app_id>/', views.hr_application_view,
|
||||
name="view"),
|
||||
url(r'^personal/view/(\w+)', views.hr_application_personal_view,
|
||||
path('personal/view/<int:app_id>/', views.hr_application_personal_view,
|
||||
name="personal_view"),
|
||||
url(r'^personal/removal/(\w+)',
|
||||
path('personal/removal/<int:app_id>/',
|
||||
views.hr_application_personal_removal,
|
||||
name="personal_removal"),
|
||||
url(r'^approve/(\w+)', views.hr_application_approve,
|
||||
path('approve/<int:app_id>/', views.hr_application_approve,
|
||||
name="approve"),
|
||||
url(r'^reject/(\w+)', views.hr_application_reject,
|
||||
path('reject/<int:app_id>/', views.hr_application_reject,
|
||||
name="reject"),
|
||||
url(r'^search/', views.hr_application_search,
|
||||
path('search/', views.hr_application_search,
|
||||
name="search"),
|
||||
url(r'^mark_in_progress/(\w+)', views.hr_application_mark_in_progress,
|
||||
path('mark_in_progress/<int:app_id>/', views.hr_application_mark_in_progress,
|
||||
name="mark_in_progress"),
|
||||
]
|
||||
]
|
||||
|
||||
@@ -219,7 +219,7 @@ def hr_application_search(request):
|
||||
Q(user__character_ownerships__character__corporation_name__icontains=searchstring) |
|
||||
Q(user__character_ownerships__character__alliance_name__icontains=searchstring) |
|
||||
Q(user__username__icontains=searchstring)
|
||||
)
|
||||
).distinct()
|
||||
|
||||
context = {'applications': applications, 'search_form': HRApplicationSearchForm()}
|
||||
|
||||
|
||||
Binary file not shown.
@@ -20,7 +20,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: es\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
|
||||
|
||||
#: allianceauth/analytics/models.py:29
|
||||
msgid "Google Analytics Universal"
|
||||
@@ -450,6 +450,7 @@ msgid "%(user)s has collected one link this month."
|
||||
msgid_plural "%(user)s has collected %(links)s links this month."
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:28
|
||||
msgid "Times used"
|
||||
@@ -461,6 +462,7 @@ msgid "%(user)s has created one link this month."
|
||||
msgid_plural "%(user)s has created %(links)s links this month."
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:48
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkview.html:27
|
||||
@@ -2141,6 +2143,7 @@ msgid "%(tasks)s task"
|
||||
msgid_plural "%(tasks)s tasks"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#: allianceauth/templates/allianceauth/night-toggle.html:6
|
||||
msgid "Night Mode"
|
||||
|
||||
Binary file not shown.
@@ -24,7 +24,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: fr_FR\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n > 1);\n"
|
||||
"Plural-Forms: nplurals=3; plural=(n == 0 || n == 1) ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
|
||||
|
||||
#: allianceauth/analytics/models.py:29
|
||||
msgid "Google Analytics Universal"
|
||||
@@ -460,6 +460,7 @@ msgid "%(user)s has collected one link this month."
|
||||
msgid_plural "%(user)s has collected %(links)s links this month."
|
||||
msgstr[0] "%(user)s a obtenu un lien ce mois."
|
||||
msgstr[1] "%(user)s a obtenu %(links)s liens ce mois."
|
||||
msgstr[2] "%(user)s a obtenu %(links)s liens ce mois."
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:28
|
||||
msgid "Times used"
|
||||
@@ -471,6 +472,7 @@ msgid "%(user)s has created one link this month."
|
||||
msgid_plural "%(user)s has created %(links)s links this month."
|
||||
msgstr[0] "%(user)s a créé un lien ce mois."
|
||||
msgstr[1] "%(user)s a créé %(links)s liens ce mois."
|
||||
msgstr[2] "%(user)s a créé %(links)s liens ce mois."
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:48
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkview.html:27
|
||||
@@ -2167,6 +2169,7 @@ msgid "%(tasks)s task"
|
||||
msgid_plural "%(tasks)s tasks"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#: allianceauth/templates/allianceauth/night-toggle.html:6
|
||||
msgid "Night Mode"
|
||||
|
||||
Binary file not shown.
@@ -20,7 +20,7 @@ msgstr ""
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: 8bit\n"
|
||||
"Language: it_IT\n"
|
||||
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
|
||||
"Plural-Forms: nplurals=3; plural=n == 1 ? 0 : n != 0 && n % 1000000 == 0 ? 1 : 2;\n"
|
||||
|
||||
#: allianceauth/analytics/models.py:29
|
||||
msgid "Google Analytics Universal"
|
||||
@@ -460,6 +460,7 @@ msgid "%(user)s has collected one link this month."
|
||||
msgid_plural "%(user)s has collected %(links)s links this month."
|
||||
msgstr[0] "%(user)s ha ottenuto un link per questo mese."
|
||||
msgstr[1] "%(user)s ha ottenuto %(links)s links questo mese."
|
||||
msgstr[2] "%(user)s ha ottenuto %(links)s links questo mese."
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:28
|
||||
msgid "Times used"
|
||||
@@ -471,6 +472,7 @@ msgid "%(user)s has created one link this month."
|
||||
msgid_plural "%(user)s has created %(links)s links this month."
|
||||
msgstr[0] "%(user)s ha creato un link questo mese."
|
||||
msgstr[1] "%(user)s ha creato %(links)s links questo mese."
|
||||
msgstr[2] "%(user)s ha creato %(links)s links questo mese."
|
||||
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkpersonalmonthlystatisticsview.html:48
|
||||
#: allianceauth/fleetactivitytracking/templates/fleetactivitytracking/fatlinkview.html:27
|
||||
@@ -2155,6 +2157,7 @@ msgid "%(tasks)s task"
|
||||
msgid_plural "%(tasks)s tasks"
|
||||
msgstr[0] ""
|
||||
msgstr[1] ""
|
||||
msgstr[2] ""
|
||||
|
||||
#: allianceauth/templates/allianceauth/night-toggle.html:6
|
||||
msgid "Night Mode"
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "Notifications" %}{% endblock %}
|
||||
@@ -9,15 +8,15 @@
|
||||
|
||||
<div class="panel panel-default">
|
||||
|
||||
<div class="panel-heading">
|
||||
<ul class="nav nav-pills">
|
||||
<div class="panel-heading clearfix">
|
||||
<ul class="nav nav-pills navbar-left">
|
||||
<li class="active"><a data-toggle="tab" href="#unread">{% translate "Unread" %}<b>({{ unread|length }})</b></a></li>
|
||||
<li><a data-toggle="tab" href="#read">{% translate "Read" %} <b>({{ read|length }})</b></a></li>
|
||||
<div class="pull-right">
|
||||
<a href="{% url 'notifications:mark_all_read' %}" class="btn btn-warning">{% translate "Mark All Read" %}</a>
|
||||
<a href="{% url 'notifications:delete_all_read' %}" class="btn btn-danger">{% translate "Delete All Read" %}</a>
|
||||
</div>
|
||||
</ul>
|
||||
<div class="nav navbar-nav navbar-right" style="margin-right: 0;">
|
||||
<a href="{% url 'notifications:mark_all_read' %}" class="btn btn-warning">{% translate "Mark All Read" %}</a>
|
||||
<a href="{% url 'notifications:delete_all_read' %}" class="btn btn-danger">{% translate "Delete All Read" %}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block page_title %}{% translate "View Notification" %}{% endblock page_title %}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
from . import views
|
||||
|
||||
app_name = 'notifications'
|
||||
# Notifications
|
||||
urlpatterns = [
|
||||
url(r'^remove_notifications/(\w+)/$', views.remove_notification, name='remove'),
|
||||
url(r'^notifications/mark_all_read/$', views.mark_all_read, name='mark_all_read'),
|
||||
url(r'^notifications/delete_all_read/$', views.delete_all_read, name='delete_all_read'),
|
||||
url(r'^notifications/$', views.notification_list, name='list'),
|
||||
url(r'^notifications/(\w+)/$', views.notification_view, name='view'),
|
||||
url(
|
||||
r'^user_notifications_count/(?P<user_pk>\d+)/$',
|
||||
path('remove_notifications/<int:notif_id>/', views.remove_notification, name='remove'),
|
||||
path('notifications/mark_all_read/', views.mark_all_read, name='mark_all_read'),
|
||||
path('notifications/delete_all_read/', views.delete_all_read, name='delete_all_read'),
|
||||
path('notifications/', views.notification_list, name='list'),
|
||||
path('notifications/<int:notif_id>/', views.notification_view, name='view'),
|
||||
path(
|
||||
'user_notifications_count/<int:user_pk>/',
|
||||
views.user_notifications_count,
|
||||
name='user_notifications_count'
|
||||
),
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
default_app_config = 'allianceauth.optimer.apps.OptimerConfig'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from allianceauth import hooks
|
||||
from . import urls
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from allianceauth.optimer.form_widgets import DataListWidget
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
@@ -19,7 +18,7 @@
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Create Fleet Operation" %}</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
@@ -21,7 +20,7 @@
|
||||
<b>{% translate "Current Eve Time:" %} </b>
|
||||
</div>
|
||||
<strong class="label label-info text-left" id="current-time"></strong>
|
||||
<br />
|
||||
<br>
|
||||
</div>
|
||||
|
||||
<h4><b>{% translate "Next Fleet Operations" %}</b></h4>
|
||||
@@ -40,9 +39,9 @@
|
||||
</div>
|
||||
|
||||
{% include 'bundles/moment-js.html' with locale=True %}
|
||||
<script src="{% static 'js/timers.js' %}"></script>
|
||||
{% include 'bundles/timers-js.html' %}
|
||||
|
||||
<script type="application/javascript">
|
||||
<script>
|
||||
// Data
|
||||
let timers = [
|
||||
{% for op in optimer %}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{% extends "allianceauth/base.html" %}
|
||||
{% load bootstrap %}
|
||||
{% load static %}
|
||||
{% load i18n %}
|
||||
{% get_current_language as LANGUAGE_CODE %}
|
||||
|
||||
@@ -24,7 +23,7 @@
|
||||
<form class="form-signin" role="form" action="" method="POST">
|
||||
{% csrf_token %}
|
||||
{{ form|bootstrap }}
|
||||
<br/>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">{% translate "Update Fleet Operation" %}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
from django.conf.urls import url
|
||||
from django.urls import path
|
||||
|
||||
from . import views
|
||||
|
||||
app_name = 'optimer'
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', views.optimer_view, name='view'),
|
||||
url(r'^add$', views.add_optimer_view, name='add'),
|
||||
url(r'^(\w+)/remove$', views.remove_optimer, name='remove'),
|
||||
url(r'^(\w+)/edit$', views.edit_optimer, name='edit'),
|
||||
]
|
||||
path('', views.optimer_view, name='view'),
|
||||
path('add/', views.add_optimer_view, name='add'),
|
||||
path('<int:optimer_id>/remove/', views.remove_optimer, name='remove'),
|
||||
path('<int:optimer_id>/edit/', views.edit_optimer, name='edit'),
|
||||
]
|
||||
|
||||
@@ -6,7 +6,7 @@ from django.contrib.auth.decorators import permission_required
|
||||
from django.shortcuts import get_object_or_404
|
||||
from django.shortcuts import render, redirect
|
||||
from django.utils import timezone
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from .form import OpForm
|
||||
|
||||
from .models import OpTimer, OpTimerType
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user