Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP django3.2 python 3.10 support #3731

Draft
wants to merge 5 commits into
base: ng
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
branches: [ ng ]
pull_request:
# The branches below must be a subset of the branches above
branches: [ ng ]
schedule:
- cron: '39 7 * * 4'

jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript', 'python' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support

steps:
- name: Checkout repository
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality


# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun

# If the Autobuild fails above, remove it and uncomment the following three lines.
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.

# - run: |
# echo "Run, Build Application using script"
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Ralph

This is a next gen fork of Ralph,
keeping in line with current django LTS (3.2) and recent python (3.10)
Ralph is full-featured Asset Management, DCIM and CMDB system for data centers and back offices.

Features:
Expand Down
72 changes: 35 additions & 37 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
-r openstack.txt
-r hermes.txt
Django==1.8.19
dj.choices==0.11.0
django-extensions==1.7.5
django-filter==0.13.0
django-import-export==0.4.2
django-money==0.15.1
py-moneyed==1.2
django-mptt==0.8.7
django-reversion==1.8.6
django-rq==2.0
django-sitetree==1.7.0
django-taggit==0.17.1
django-taggit-serializer==0.1.5
django-threadlocals==0.8
django-transaction-hooks==0.2 # it's merged to Django 1.9 - remove this when Django version will be bumped to 1.9
django-cryptography==0.3
djangorestframework==3.2.2
djangorestframework_xml==1.2.0
drf-nested-routers==0.11.1
Django>=3.2.0
dj.choices>=0.11.0
django-extensions>=1.7.5
django-filter>=0.13.0
django-import-export>=0.4.2
django-money>=0.15.1
py-moneyed>=1.2
django-mptt>=0.8.7
django-reversion>=1.8.6
django-rq>=2.0
django-sitetree>=1.7.0
django-taggit>=0.17.1
django-taggit-serializer>=0.1.5
django-threadlocals>=0.8
django-cryptography>=0.3
djangorestframework>=3.2.2
djangorestframework_xml>=1.2.0
drf-nested-routers>=0.11.1
Markdown<3.0 # headerid extension removed in 3.0 - see #3313 for details
mysqlclient==1.3.13
netaddr==0.7.18
python-dateutil==2.4.2
pytz==2015.4
redis==3.2.1
requests==2.20.0
requests-oauthlib==1.3.0
rq==1.0
#mysqlclient>=1.3.13 # only required if using mysql, can also work with postgres or other db servers
netaddr>=0.7.18
python-dateutil>=2.4.2
pytz>=2015.4
redis>=3.2.1
requests>=2.20.0
requests-oauthlib>=1.3.0
rq>=1.0
six>=1.9.0
sqlparse==0.2.3
Unidecode==0.04.18
tablib==0.11.5
factory-boy==2.11.1
Faker==0.9.0
openpyxl==2.4.0
typing==3.6.6
Pillow==6.2.2

sqlparse>=0.2.3
Unidecode>=0.04.18
tablib>=0.11.5
factory-boy>=2.11.1
Faker>=0.9.0
openpyxl>=2.4.0
typing>=3.6.6
Pillow>=6.2.2
statsd
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-r test.txt
django-debug-toolbar==1.8
django-debug-toolbar>=1.11.1
werkzeug==0.16.1
pudb
ipython
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mkdocs==1.1
mkdocs>=1.2.3
mkdocs-material==5.1.1
mkdocs-bootswatch==1.1
mkdocs_bootstrap==1.1
2 changes: 1 addition & 1 deletion requirements/openstack.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python-keystoneclient==2.3.0
python-novaclient==3.2.0
python-ironicclient==1.7.1

Babel==2.2.0
Babel>=2.9.1
debtcollector==1.3.0
funcsigs==0.4
iso8601==0.1.11
Expand Down
3 changes: 2 additions & 1 deletion src/ralph/access_cards/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.utils.translation import ugettext_lazy as _

from ralph.access_cards.models import AccessCard, AccessZone
from ralph.admin import RalphAdmin, RalphMPTTAdmin, register
from ralph.admin.mixins import RalphAdmin, RalphMPTTAdmin
from ralph.admin.decorators import register
from ralph.lib.transitions.admin import TransitionAdminMixin


Expand Down
3 changes: 2 additions & 1 deletion src/ralph/access_cards/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def __str__(self):
null=True,
blank=True,
related_name='children',
db_index=True
db_index=True,
on_delete=models.CASCADE,
)


Expand Down
3 changes: 2 additions & 1 deletion src/ralph/accessories/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.utils.translation import ugettext_lazy as _

from ralph.accessories.models import Accessory, AccessoryUser
from ralph.admin import RalphAdmin, RalphTabularInline, register
from ralph.admin.mixins import RalphAdmin, RalphTabularInline
from ralph.admin.decorators import register
from ralph.admin.views.extra import RalphDetailViewAdmin
from ralph.lib.transitions.admin import TransitionAdminMixin

Expand Down
8 changes: 5 additions & 3 deletions src/ralph/accessories/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class Accessory(
Manufacturer, on_delete=models.PROTECT, blank=True, null=True
)
category = TreeForeignKey(
Category, null=True, related_name='+'
Category, null=True, related_name='+',
on_delete=models.CASCADE,
)
accessory_name = models.CharField(
max_length=255,
Expand Down Expand Up @@ -215,10 +216,11 @@ def free(self):

@reversion.register()
class AccessoryUser(models.Model):
accessory = models.ForeignKey(Accessory)
accessory = models.ForeignKey(Accessory, on_delete=models.CASCADE)
user = models.ForeignKey(
settings.AUTH_USER_MODEL,
related_name='user'
related_name='user',
on_delete=models.CASCADE,
)
quantity = models.PositiveIntegerField(default=1)

Expand Down
7 changes: 4 additions & 3 deletions src/ralph/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@
from django.contrib.auth.admin import GroupAdmin, UserAdmin
from django.contrib.auth.models import Group
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.db.models import Q
from django.forms.models import model_to_dict
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _

from ralph.accounts.models import RalphUser, Region, Team
from ralph.admin import RalphAdmin, register
from ralph.admin.mixins import RalphAdmin
from ralph.admin.decorators import register
from ralph.admin.helpers import getattr_dunder
from ralph.admin.mixins import RalphAdminFormMixin
from ralph.admin.views.extra import RalphDetailView
from ralph.back_office.models import BackOfficeAsset
from ralph.lib.table import Table
from ralph.lib.table.table import Table
from ralph.lib.transitions.models import TransitionsHistory
from ralph.licences.models import Licence
from ralph.sim_cards.models import SIMCard
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/accounts/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from urllib.parse import urlencode

from django.conf import settings
from django.core.urlresolvers import reverse
from django.urls import reverse

from ralph.access_cards.models import AccessCard
from ralph.admin.sites import ralph_site
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/accounts/management/commands/ldap_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import sys
import textwrap
from collections import defaultdict
from functools import lru_cache

from django.conf import settings
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Group
from django.core.management.base import BaseCommand
from django.utils.lru_cache import lru_cache
from ldap.controls import SimplePagedResultsControl

from ralph.helpers import cache
Expand Down
6 changes: 3 additions & 3 deletions src/ralph/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ralph.admin.autocomplete import AutocompleteTooltipMixin
from ralph.lib.mixins.models import AdminAbsoluteUrlMixin, NamedMixin
from ralph.lib.permissions import (
from ralph.lib.permissions.models import (
PermByFieldMixin,
PermissionsForObjectMixin,
user_permission
Expand Down Expand Up @@ -50,7 +50,7 @@ def object_has_region(user):


class Regionalizable(PermissionsForObjectMixin):
region = models.ForeignKey(Region, blank=False, null=False)
region = models.ForeignKey(Region, blank=False, null=False, on_delete=models.CASCADE)

class Meta:
abstract = True
Expand Down Expand Up @@ -121,7 +121,7 @@ class RalphUser(
blank=True,
)
regions = models.ManyToManyField(Region, related_name='users', blank=True)
team = models.ForeignKey(Team, null=True, blank=True)
team = models.ForeignKey(Team, null=True, blank=True, on_delete=models.CASCADE)

autocomplete_tooltip_fields = [
'employee_id',
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/accounts/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.conf import settings
from django.contrib.auth.hashers import check_password
from django.contrib.auth.models import Permission
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.test import TestCase
from rest_framework import status

Expand Down
10 changes: 5 additions & 5 deletions src/ralph/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.conf.urls import url
from django.urls import re_path
from django.contrib.auth.decorators import login_required

from ralph.accounts.views import (
Expand All @@ -9,23 +9,23 @@
)

urlpatterns = [
url(
re_path(
r'^user_profile/?$',
login_required(UserProfileView.as_view()),
name='user_profile'
),
url(
re_path(
r'^my_equipment/?$',
login_required(CurrentUserInfoView.as_view()),
name='current_user_info'
),
url(
re_path(
r'^my_equipment/inventory_tag/'
r'(?P<asset_id>[0-9]+)/(?P<answer>yes|no)/$',
login_required(InventoryTagConfirmationView.as_view()),
name='inventory_tag_confirmation'
),
url(
re_path(
r'^my_equipment/inventory_tag/$',
login_required(InventoryTagView.as_view()),
name='inventory_tag'
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import reversion
from django.conf import settings
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpResponseForbidden, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.utils.translation import ugettext_lazy as _
Expand Down
10 changes: 0 additions & 10 deletions src/ralph/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
from ralph.admin.sites import ralph_site
from ralph.admin.mixins import (
RalphAdmin,
RalphAdminForm,
RalphMPTTAdmin,
RalphStackedInline,
RalphTabularInline,
)
from ralph.admin.decorators import register

default_app_config = 'ralph.admin.apps.RalphAdminConfig'

__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/admin/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from ralph.admin.filters import register_custom_filters
from ralph.apps import RalphAppConfig


Expand All @@ -9,5 +8,6 @@ class RalphAdminConfig(RalphAppConfig):
verbose_name = 'Ralph Admin'

def ready(self):
from ralph.admin.filters import register_custom_filters
register_custom_filters()
super().ready()
Loading