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

Django 2.1 #3863

Merged
merged 10 commits into from
Nov 28, 2024
Merged
6 changes: 3 additions & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
-r openstack.txt
-r hermes.txt
Django==2.0.13
Django==2.1.15
Faker==0.9.0
Markdown<3.0 # headerid extension removed in 3.0 - see #3313 for details
Pillow==6.2.2
Unidecode==0.04.18
dj.choices==0.11.0
django-cryptography==0.3
django-extensions==2.2.9
django-filter==1.0.4
django-filter==2.0.0
django-import-export==1.2.0
django-money==0.12.3
django-mptt==0.11
Expand All @@ -18,7 +18,7 @@ django-sitetree==1.13.0
django-taggit-serializer==0.1.7
django-taggit==0.22.2
django-threadlocals==0.8
djangorestframework==3.7.5
djangorestframework==3.8.2
djangorestframework_xml==1.2.0
drf-nested-routers==0.11.1
factory-boy==2.11.1
Expand Down
5 changes: 3 additions & 2 deletions src/ralph/admin/templates/admin/includes/javascripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@
var group_id = $(this).data('group-id'),
prefix = $(this).data('prefix'),
add_text = $(this).data('add-text'),
delete_text = $(this).data('delete-text');
delete_text = $(this).data('delete-text'),
selector = "#" + group_id + "-group .tabular.inline-related tbody tr";
(function($) {
$("#" + group_id + "-group .tabular.inline-related tbody tr").tabularFormset({
$(selector).tabularFormset(selector, {
prefix: prefix,
addText: add_text,
deleteText: delete_text
Expand Down
3 changes: 3 additions & 0 deletions src/ralph/admin/tests/tests_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from ralph.admin.views.extra import RalphDetailView, RalphListView
from ralph.admin.views.main import RalphChangeList
from ralph.tests.admin import CarAdmin, ManufacturerAdmin
from ralph.tests.factories import UserFactory
from ralph.tests.mixins import ClientMixin, ReloadUrlsMixin
from ralph.tests.models import Car, Foo, TestManufacturer

Expand Down Expand Up @@ -254,12 +255,14 @@ def _change_list_factory(
model=model,
model_admin=model_admin(model, ralph_site),
request=request,
sortable_by=model_admin.sortable_by,
)

def _get_ordering_list(self, model, model_admin, params, list_display):
from django.contrib.admin.views.main import ORDER_VAR
get_params = '{}={}'.format(ORDER_VAR, '.'.join(map(str, params)))
request = RequestFactory().get('/?' + get_params)
request.user = UserFactory()
cl = self._change_list_factory(
model=Car,
model_admin=CarAdmin,
Expand Down
6 changes: 3 additions & 3 deletions src/ralph/admin/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def media(self):
static(path) for path in js
])

def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
attrs['class'] = self.css_class
return super().render(name, value, attrs=attrs)
return super().render(name, value, attrs=attrs, renderer=renderer)


class AdminDateWidget(DatepickerWidgetMixin, forms.DateInput):
Expand Down Expand Up @@ -256,7 +256,7 @@ def render_search_fields_info(self, search_fields):
rows.append("- {}\n".format(field))
return ''.join(rows)

def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
model_options = (
self.rel_to._meta.app_label, self.rel_to._meta.model_name
)
Expand Down
4 changes: 2 additions & 2 deletions src/ralph/assets/api/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class NetworkableObjectFilters(django_filters.FilterSet):
Base filter for all networkable objects for example with IP address.
"""
configuration_path = django_filters.CharFilter(
name='configuration_path__path'
field_name='configuration_path__path'
)
ip = django_filters.CharFilter(name='ethernet_set__ipaddress__address')
ip = django_filters.CharFilter(field_name='ethernet_set__ipaddress__address')

class Meta:
fields = [
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/assets/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class EnvironmentViewSet(RalphAPIViewSet):


class ServiceFilterSet(django_filters.FilterSet):
active = BooleanFilter(name="active")
active = BooleanFilter(field_name="active")

class Meta:
model = models.Service
Expand Down
4 changes: 3 additions & 1 deletion src/ralph/lib/custom_fields/tests/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib import admin

from ..admin import CustomFieldValueAdminMixin
from ..admin import CustomFieldAdmin, CustomFieldValueAdminMixin
from ..models import CustomField
from .models import ModelA, ModelB, SomeModel

site = admin.AdminSite(name="cf_admin")
Expand All @@ -24,3 +25,4 @@ class ModelBAdmin(CustomFieldValueAdminMixin, admin.ModelAdmin):
site.register(SomeModel, SomeModelAdmin)
site.register(ModelA, ModelAAdmin)
site.register(ModelB, ModelBAdmin)
site.register(CustomField, CustomFieldAdmin)
2 changes: 1 addition & 1 deletion src/ralph/lib/custom_fields/tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_get_customfield_formfield_for_string_field(self):
# default_value should be placed
self.assertContains(
response,
'<input type="text" name="__empty__" value="xyz" />'
'<input type="text" name="__empty__" value="xyz">'
)

def test_add_new_custom_field_value_for_existing_object(self):
Expand Down
8 changes: 4 additions & 4 deletions src/ralph/lib/mixins/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ def clean(self, value, model_instance):


class TicketIdFieldWidget(AdminTextInputWidget):
def render(self, name, value, attrs=None):
html = super().render(name, value, attrs)
def render(self, name, value, attrs=None, renderer=None):
html = super().render(name, value, attrs, renderer)
if value:
url = '{}{}'.format(settings.ISSUE_TRACKER_URL, value)
final_attrs = {'href': smart_urlquote(url), 'target': '_blank'}
Expand Down Expand Up @@ -256,15 +256,15 @@ def get_limit_models(self):


class TagWidget(forms.TextInput):
def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
if value is not None and not isinstance(value, six.string_types):
value = ', '.join(sorted([
(t if ',' not in t else '"%s"' % t) for t in value
]))
if attrs is None:
attrs = {}
attrs['class'] = 'vTextField'
return super(TagWidget, self).render(name, value, attrs)
return super(TagWidget, self).render(name, value, attrs, renderer)


class TaggitTagField(TagField):
Expand Down
4 changes: 2 additions & 2 deletions src/ralph/lib/mixins/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ def _get_other_field(self, name, value):
name=OTHER_NAME.format(name), value=value.get(OTHER) or ''
)

def render(self, name, value, attrs=None):
def render(self, name, value, attrs=None, renderer=None):
show_other = value and value.get('value') == OTHER
choice_value = (value.get('value') if value else '') or ''
return mark_safe(
'<div class="{}">{}{}</div>'.format(
self.css_class,
super().render(name, choice_value, attrs=attrs),
super().render(name, choice_value, attrs=attrs, renderer=renderer),
self._get_other_field(name, value) if show_other else ''
)
)
Expand Down
2 changes: 1 addition & 1 deletion src/ralph/security/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def to_internal_value(self, data):

class IPFilter(django_filters.FilterSet):
ip = django_filters.CharFilter(
name='base_object__ethernet_set__ipaddress__address'
field_name='base_object__ethernet_set__ipaddress__address'
)

class Meta:
Expand Down
Loading