Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/xml-editor' into issue-1398
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpatiiuk committed Apr 19, 2023
2 parents 93babd6 + 20725dc commit 0360179
Show file tree
Hide file tree
Showing 205 changed files with 12,071 additions and 2,033 deletions.
23 changes: 14 additions & 9 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'type:bug, pri:unknown'
assignees: ''

title: ""
labels: "type:bug, pri:unknown"
assignees: ""
---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -23,12 +23,17 @@ A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop:**
- OS: [e.g. Windows 10]
- Browser: [e.g. Chrome, Safari]
- Specify 7 Version: [e.g. 7.6.1]
**Crash Report**

If the bug resulted in an error message, please click on "Download Error
Message" and attach it here

Alternatively, please fill out the following information manually:

**Database Name:** If applicable
- OS: [e.g. Windows 10]
- Browser: [e.g. Chrome, Safari]
- Specify 7 Version: [e.g. 7.6.1]
- Database Name: [e.g. kufish] (you can see this in the "About Specify 7" dialog)

**Reported By**
Name of your institution
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ jobs:
if: steps.changed.outputs.changed
working-directory: specifyweb/frontend/js_src
run: |
npx prettier --write --minify `echo "${{steps.changed.outputs.changed}}" | tr " " "\n"`
npx prettier --write --minify `echo "${{steps.changed.outputs.changed}}" | tr " " "\n"` || true
- name: Commit linted files (if made any changes)
working-directory: specifyweb/frontend/js_src
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,34 @@ Coming in the next few months:

## [7.8.9](https://github.com/specify/specify7/compare/v7.8.7...HEAD) (Unreleased)

## [7.8.8](https://github.com/specify/specify7/compare/v7.8.7.1...v7.8.8) (March 20 2023)

### Added

- A new warning for attachments that are too large to upload has been
added ([#729](https://github.com/specify/specify7/issues/729))
- A webpack visualizer has been added for development purposes ([#3119](https://github.com/specify/specify7/pull/3119))

### Fixed

- "Export to KML" functionality has been returned ([#3088](https://github.com/specify/specify7/issues/3088) - *Reported
by CSIRO*)
- Fixed issue that prevented some users from merging items in the
trees ([#3133](https://github.com/specify/specify7/pull/3133) - *Reported by RBGE and AAFC*)
- Display issues preventing the "Name" field from displaying in the Security & Accounts panel has been resolved
- ([#3140](https://github.com/specify/specify7/issues/3140) - *Reported by SAIAB*)
- Record sets can no longer have a negative index value ([#3033](https://github.com/specify/specify7/issues/3033))
- The color picker is now correctly positioned in Safari ([#2215](https://github.com/specify/specify7/issues/2215))
- The default export delimiter is once again "Comma" instead of "
Tab" ([#3106](https://github.com/specify/specify7/issues/3106) - *Reported by FWRI*)
- Fixed some app resources not displaying due to a scoping bug ([#3014](https://github.com/specify/specify7/issues/3104)
- *Reported by SAIAB*)
- System information is now stored in the stack
trace ([5be8ece](https://github.com/specify/specify7/commit/5be8ece6cd5937354622b9efae162a9cd7aeb329))
- Header overflowing has been resolved in the App Resources
viewer ([#3103](https://github.com/specify/specify7/issues/3103))


## [7.8.7.1](https://github.com/specify/specify7/compare/v7.8.7...v7.8.7.1) (March 3 2023)

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ database both though Django ORM and though SQLAlchemy.
Back-end root directory
is [./specifyweb/](https://github.com/specify/specify7/tree/production/specifyweb)

[We have a video of a full back-end overview from January 2023 available here](https://drive.google.com/file/d/1OW60g99aiPw1Y8uHdCUxZCiVnLbFhObG/view?usp=sharing)

## IDE Setup

No special IDE configuration is required, but some optional plugins would
Expand Down
3 changes: 2 additions & 1 deletion specifyweb/context/app_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def load_resource_at_level(collection, user, level, resource_name):
def get_path_for_level(collection, user, level):
"""Build the filesystem path for a given resource level."""

discipline_dir = discipline_dirs.get(collection.discipline.type, None)
discipline_dir = None if collection is None else \
discipline_dirs.get(collection.discipline.type, None)
usertype = get_usertype(user)

paths = {
Expand Down
5 changes: 2 additions & 3 deletions specifyweb/context/tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import json

from django.test import TestCase, Client
from jsonschema import validate # type: ignore
from jsonschema.exceptions import ValidationError # type: ignore

from django.test import TestCase, TransactionTestCase, Client

from specifyweb.specify import models, api
from specifyweb.specify.api_tests import ApiTests
from . import viewsets


class ViewTests(ApiTests):
def setUp(self):
super(ViewTests, self).setUp()
Expand Down
4 changes: 3 additions & 1 deletion specifyweb/context/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Defines the urls for the app context subsystem
"""

from django.conf.urls import include, url
from django.conf.urls import url
from django.urls import path

from . import views, user_resources
Expand All @@ -22,6 +22,8 @@
url(r'^system_info.json$', views.system_info),
url(r'^domain.json$', views.domain),
url(r'^view.json$', views.view),
url(r'^views.json$', views.views),
url(r'^viewsets.json$', views.viewsets),
url(r'^datamodel.json$', views.datamodel),
url(r'^schema_localization.json$', views.schema_localization),
url(r'^app.resource$', views.app_resource),
Expand Down
159 changes: 126 additions & 33 deletions specifyweb/context/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
from .app_resource import get_app_resource
from .remote_prefs import get_remote_prefs
from .schema_localization import get_schema_languages, get_schema_localization
from .viewsets import get_view
from .viewsets import get_views


def set_collection_cookie(response, collection_id):
Expand Down Expand Up @@ -397,36 +397,52 @@ def schema_localization(request):
lang = request.GET.get('lang', request.LANGUAGE_CODE)
return JsonResponse(get_schema_localization(request.specify_collection, 0, lang))

view_parameters_schema = [
{
"name" : "name",
"in":"query",
"required" : False,
"schema": {
"type": "string"
},
"description" : "The name of the view to fetch"
},
{
"name": "table",
"in": "query",
"required": False,
"schema": {
"type": "string"
},
"description": "Table name to restrict views to. Either this or 'name' must be provided, but not both"
},
]

@openapi(schema={
"parameters": [
{
"name" : "name",
"in":"query",
"required" : True,
"schema": {
"type": "string"
},
"description" : "The name of the view to fetch"
*view_parameters_schema,
{
"name": "quiet",
"in": "query",
"required": False,
"schema": {
"type": "boolean",
"default": False,
},
{
"name" : "quiet",
"in": "query",
"required" : False,
"schema": {
"type": "boolean",
"default": False,
},
"allowEmptyValue": True,
"description": "Flag to indicate that if the view does not exist, return response with code 204 instead of 404"
}
],
"allowEmptyValue": True,
"description": "Flag to indicate that if the view does not exist, return response with code 204 instead of 404"
}
],
"get" : {
"responses": {
"404": {
"description": "'name' parameter was not provided, or view was not found"
},
"204": {
"description" : "View was not found but 'quiet' flag was provided"
},
"200": {
"description": "View definition",
}
}
}
Expand All @@ -436,25 +452,102 @@ def schema_localization(request):
@cache_control(max_age=86400, private=True)
def view(request):
"""Return a Specify view definition by name taking into account the logged in user and collection."""
quiet = "quiet" in request.GET and request.GET['quiet'].lower() != 'false'
# If view can not be found, return 204 if quiet and 404 otherwise
data = view_helper(request,1)
if not data:
quiet = \
"quiet" in request.GET and request.GET['quiet'].lower() != 'false'
if quiet: return HttpResponse(status=204)
raise Http404("view: %s not found", request.GET['name'] if 'name' in request.GET else request.GET['table'])
return HttpResponse(json.dumps(data[0]), content_type="application/json")

@openapi(schema={
"parameters": [
*view_parameters_schema,
{
"name": "limit",
"in": "query",
"required": False,
"schema": {
"type": "number",
"default": 0,
},
"allowEmptyValue": True,
"description": "Maximum number of view definitions to return. Default - no limit"
}
],
"get" : {
"responses": {
"200": {
"description": "View definition",
}
}
}
})
@require_http_methods(['GET', 'HEAD'])
@login_maybe_required
@cache_control(max_age=86400, private=True)
def views(request):
"""
Return all Specify view definitions for a given table or by name taking
into account the logged in user and collection.
"""
try:
limit = int(request.GET['limit'])
except:
limit = 0
data = view_helper(request,limit)
return HttpResponse(json.dumps(data), content_type="application/json")

@openapi(schema={
"get": {
"responses": {
"200": {
"description": "List of Specify 6 viewset xml files",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "string",
}
},
},
},
}
}
}
})
@require_http_methods(['GET', 'HEAD'])
@login_maybe_required
@cache_control(max_age=86400, private=True)
def viewsets(request):
"""Retrive a list of Specify 6 viewset xml files."""
viewsets = []
for root, dir, files in os.walk(settings.SPECIFY_CONFIG_DIR):
for file in files:
if file.endswith('.views.xml'):
viewsets.append(
os.path.relpath(os.path.join(root, file),settings.SPECIFY_CONFIG_DIR)
)
return HttpResponse(json.dumps(viewsets), content_type="application/json")


def view_helper(request, limit):
if 'collectionid' in request.GET:
# Allow a URL parameter to override the logged in collection.
collection = Collection.objects.get(id=request.GET['collectionid'])
else:
collection = request.specify_collection

try:
view_name = request.GET['name']
except:
raise Http404()
view_name = request.GET['name'] if 'name' in request.GET else None
table = request.GET['table'] if 'table' in request.GET else None
if view_name is None and table is None:
raise Http404("'table' or 'name' must be provided.")
if view_name is not None and table is not None:
raise Http404("'table' and 'name' can not be provided together.")

# If view can not be found, return 204 if quiet and 404 otherwise
try:
data = get_view(collection, request.specify_user, view_name)
except Http404 as exception:
if quiet: return HttpResponse(status=204)
raise exception
return HttpResponse(json.dumps(data), content_type="application/json")
return get_views(collection, request.specify_user, view_name, limit, table)

@require_http_methods(['GET', 'HEAD'])
@login_maybe_required
Expand Down
Loading

0 comments on commit 0360179

Please sign in to comment.