-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Moves the `swid_measurement` API endpoint to `swid-measurement`, and requires the submitted data to be contained in a JSON object (`data` member). The API requires basic authentication and the user must either have the `is_staff=1` flag set or the `front.write_access` permission assigned (this is the case for the `admin-user`). - SWID tags are only updated when imported via management command, not via API (only entity names are updated). - API fields are restrictable using the `fields=` parameter. - Default users and root user have been removed from the databases. They can be added with `./manage.py setpassword` and `./manage.py createsuperuser --database meta`, respectively. - Adding files and package versions in the GUI are possible. - Several other improvements regarding paging/filtering, AJAX loading, the SWID Inventory, timezone handling and many other things are included too. Closes #12.
- Loading branch information
Showing
102 changed files
with
3,439 additions
and
1,618 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import print_function, division, absolute_import, unicode_literals | ||
|
||
try: | ||
from djangorestframework_camel_case.parser import camel_to_underscore | ||
except ImportError: | ||
camel_to_underscore = lambda x: x | ||
|
||
|
||
class DynamicFieldsMixin(object): | ||
""" | ||
A serializer mixin that takes an additional `fields` argument that controls | ||
which fields should be displayed. | ||
If the djangorestframework_camel_case package is installed, the field names | ||
are converted from camelCase to under_scores. | ||
Usage:: | ||
class MySerializer(DynamicFieldsMixin, serializers.HyperlinkedModelSerializer): | ||
class Meta: | ||
model = MyModel | ||
""" | ||
def __init__(self, *args, **kwargs): | ||
super(DynamicFieldsMixin, self).__init__(*args, **kwargs) | ||
request = self.context.get('request') | ||
if request: | ||
fields = request.QUERY_PARAMS.get('fields') | ||
if fields: | ||
fields = fields.split(',') | ||
fields = map(camel_to_underscore, fields) | ||
# Drop any fields that are not specified in the `fields` argument. | ||
allowed = set(fields) | ||
existing = set(self.fields.keys()) | ||
for field_name in existing - allowed: | ||
self.fields.pop(field_name) |
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,24 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Helper functions used for API-related tasks. | ||
""" | ||
from __future__ import print_function, division, absolute_import, unicode_literals | ||
|
||
from rest_framework.response import Response | ||
|
||
|
||
def make_message(message, status_code): | ||
""" | ||
Generate and return an API Response. | ||
Args: | ||
message: | ||
The message to be returned in the response. | ||
status_code: | ||
The HTTP status code for the response. | ||
Returns: | ||
A :class:`rest_framework.response.Response` instance. | ||
""" | ||
return Response({'detail': message}, status=status_code) |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.