-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'devel' into typeerror-py3.13.1
- Loading branch information
Showing
136 changed files
with
2,020 additions
and
1,325 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,54 @@ | ||
import warnings | ||
|
||
from rest_framework.permissions import AllowAny | ||
from rest_framework.schemas import SchemaGenerator, AutoSchema as DRFAuthSchema | ||
|
||
from drf_yasg.views import get_schema_view | ||
from drf_yasg import openapi | ||
from drf_yasg.inspectors import SwaggerAutoSchema | ||
from drf_yasg.views import get_schema_view | ||
|
||
|
||
class SuperUserSchemaGenerator(SchemaGenerator): | ||
def has_view_permissions(self, path, method, view): | ||
# | ||
# Generate the Swagger schema as if you were a superuser and | ||
# permissions didn't matter; this short-circuits the schema path | ||
# discovery to include _all_ potential paths in the API. | ||
# | ||
return True | ||
|
||
class CustomSwaggerAutoSchema(SwaggerAutoSchema): | ||
"""Custom SwaggerAutoSchema to add swagger_topic to tags.""" | ||
|
||
class AutoSchema(DRFAuthSchema): | ||
def get_link(self, path, method, base_url): | ||
link = super(AutoSchema, self).get_link(path, method, base_url) | ||
def get_tags(self, operation_keys=None): | ||
tags = [] | ||
try: | ||
serializer = self.view.get_serializer() | ||
if hasattr(self.view, 'get_serializer'): | ||
serializer = self.view.get_serializer() | ||
else: | ||
serializer = None | ||
except Exception: | ||
serializer = None | ||
warnings.warn( | ||
'{}.get_serializer() raised an exception during ' | ||
'schema generation. Serializer fields will not be ' | ||
'generated for {} {}.'.format(self.view.__class__.__name__, method, path) | ||
'generated for {}.'.format(self.view.__class__.__name__, operation_keys) | ||
) | ||
|
||
link.__dict__['deprecated'] = getattr(self.view, 'deprecated', False) | ||
|
||
# auto-generate a topic/tag for the serializer based on its model | ||
if hasattr(self.view, 'swagger_topic'): | ||
link.__dict__['topic'] = str(self.view.swagger_topic).title() | ||
tags.append(str(self.view.swagger_topic).title()) | ||
elif serializer and hasattr(serializer, 'Meta'): | ||
link.__dict__['topic'] = str(serializer.Meta.model._meta.verbose_name_plural).title() | ||
tags.append(str(serializer.Meta.model._meta.verbose_name_plural).title()) | ||
elif hasattr(self.view, 'model'): | ||
link.__dict__['topic'] = str(self.view.model._meta.verbose_name_plural).title() | ||
tags.append(str(self.view.model._meta.verbose_name_plural).title()) | ||
else: | ||
warnings.warn('Could not determine a Swagger tag for path {}'.format(path)) | ||
return link | ||
tags = ['api'] # Fallback to default value | ||
|
||
if not tags: | ||
warnings.warn(f'Could not determine tags for {self.view.__class__.__name__}') | ||
return tags | ||
|
||
def get_description(self, path, method): | ||
setattr(self.view.request, 'swagger_method', method) | ||
description = super(AutoSchema, self).get_description(path, method) | ||
return description | ||
def is_deprecated(self): | ||
"""Return `True` if this operation is to be marked as deprecated.""" | ||
return getattr(self.view, 'deprecated', False) | ||
|
||
|
||
schema_view = get_schema_view( | ||
openapi.Info( | ||
title="Snippets API", | ||
default_version='v1', | ||
description="Test description", | ||
terms_of_service="https://www.google.com/policies/terms/", | ||
contact=openapi.Contact(email="[email protected]"), | ||
license=openapi.License(name="BSD License"), | ||
title='AWX API', | ||
default_version='v2', | ||
description='AWX API Documentation', | ||
terms_of_service='https://www.google.com/policies/terms/', | ||
contact=openapi.Contact(email='[email protected]'), | ||
license=openapi.License(name='Apache License'), | ||
), | ||
public=True, | ||
permission_classes=[AllowAny], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Generated by Django 4.2.16 on 2024-12-18 16:05 | ||
|
||
from django.db import migrations, models | ||
|
||
from awx.main.migrations._create_system_jobs import delete_clear_tokens_sjt | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0199_alter_oauth2application_unique_together_and_more'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(delete_clear_tokens_sjt, migrations.RunPython.noop), | ||
migrations.AlterField( | ||
model_name='systemjob', | ||
name='job_type', | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
('cleanup_jobs', 'Remove jobs older than a certain number of days'), | ||
('cleanup_activitystream', 'Remove activity stream entries older than a certain number of days'), | ||
('cleanup_sessions', 'Removes expired browser sessions from the database'), | ||
], | ||
default='', | ||
max_length=32, | ||
), | ||
), | ||
migrations.AlterField( | ||
model_name='systemjobtemplate', | ||
name='job_type', | ||
field=models.CharField( | ||
blank=True, | ||
choices=[ | ||
('cleanup_jobs', 'Remove jobs older than a certain number of days'), | ||
('cleanup_activitystream', 'Remove activity stream entries older than a certain number of days'), | ||
('cleanup_sessions', 'Removes expired browser sessions from the database'), | ||
], | ||
default='', | ||
max_length=32, | ||
), | ||
), | ||
] |
Oops, something went wrong.