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

admin views #278

Open
wants to merge 226 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
226 commits
Select commit Hold shift + click to select a range
e46d0f1
WIP
aleontiev Feb 28, 2017
4fc0a93
WIP
aleontiev Feb 28, 2017
5f44421
Merge branch 'master' of github.com:AltSchool/dynamic-rest into featu…
aleontiev Mar 1, 2017
f949a2b
processed data
aleontiev Mar 2, 2017
8503299
Improve design for details view
lynnetye Mar 6, 2017
60601bb
Provide interface for uploading file
lynnetye Mar 6, 2017
7349d99
Improve styling
lynnetye Mar 7, 2017
4aa3406
working CSV upload support
aleontiev Mar 8, 2017
d507e25
add csv upload test
aleontiev Mar 9, 2017
e96353a
Merge pull request #155 from AltSchool/feature/drest-admin-view-csv
aleontiev Mar 9, 2017
1c4e075
Merge branch 'integration/admin-view' of https://github.com/AltSchool…
lynnetye Mar 9, 2017
219eb0f
add disable envelope to list serializer
aleontiev Mar 9, 2017
75b8842
Merge branch 'integration/admin-view' of https://github.com/AltSchool…
lynnetye Mar 9, 2017
04bc4b1
Merge branch 'feature/drest-admin-view' into integration/admin-view
aleontiev Mar 9, 2017
f990be4
Merge branch 'integration/admin-view' of https://github.com/AltSchool…
lynnetye Mar 9, 2017
4310071
Consolidate templates
lynnetye Mar 17, 2017
f8e09d6
relationship support for getter/setter
aleontiev Mar 21, 2017
fe7dc7b
passing tests with self links, catch missing AdminRenderer
aleontiev Mar 21, 2017
50224ba
added changelog
aleontiev Mar 21, 2017
e65e98e
fix typo
aleontiev Mar 21, 2017
3d72a08
change renderer order
aleontiev Mar 21, 2017
2f9d550
optional get on results
aleontiev Mar 21, 2017
7d15baa
add vertical/horizontal field copies
aleontiev Mar 21, 2017
34f5401
remove 1.7 from tox
aleontiev Mar 21, 2017
3ded4a5
refactor field code locations
aleontiev Mar 21, 2017
dd976ca
Remove sidebar buttons and pluralize collection in breadcrumbs
lynnetye Mar 21, 2017
9177c5d
test groups.csv
aleontiev Mar 21, 2017
4ff6a8b
attempt to fix SUF for py3
aleontiev Mar 21, 2017
857ece3
py3 fix
aleontiev Mar 22, 2017
0f9b7bd
add back django 1.7
aleontiev Mar 22, 2017
6217256
Merge pull request #158 from AltSchool/feature/admin-view/relationships
aleontiev Mar 23, 2017
6d016b3
Fix merge conflicts
lynnetye Mar 23, 2017
38950f5
Update test
lynnetye Mar 24, 2017
8e65aac
relationship hyperlinks + natural key
aleontiev Mar 28, 2017
a3fa079
revert change to test locationviewset (pagination)
aleontiev Mar 28, 2017
317e647
remove unused queryset resolution logic in related field
aleontiev Mar 28, 2017
7bb24fe
Display .csv bulk import errors
lynnetye Mar 29, 2017
57b66d4
tweak get_url usage
aleontiev Mar 29, 2017
ac109c5
add DRF 3.1 compat for Hyperlink
aleontiev Mar 29, 2017
305b8db
Merge pull request #160 from AltSchool/lt/drest-admin-view
aleontiev Mar 29, 2017
76e2caa
Merge branch 'integration/admin-view' of github.com:AltSchool/dynamic…
aleontiev Mar 29, 2017
0fce86c
Merge pull request #159 from AltSchool/feature/admin-view/relationships
aleontiev Mar 30, 2017
c609b99
import DynamicComputedField
aleontiev Mar 30, 2017
944fdf7
Update API directory display
lynnetye Apr 3, 2017
484ee31
Update color palette
lynnetye Apr 10, 2017
f5f887c
Make responsive
lynnetye Apr 10, 2017
f8e4b39
Merge pull request #165 from AltSchool/lt/drest-admin-view-design
aleontiev Apr 10, 2017
a3271b5
Merge branch 'master' of github.com:AltSchool/dynamic-rest into integ…
aleontiev Apr 13, 2017
1d879a6
improve view name / fix directory vs detail / fix header/data order m…
aleontiev Apr 13, 2017
262aeae
tweak breadcrumbs (remove ref to root, change style)
aleontiev Apr 13, 2017
b0d3f4f
more robust natural key logic
aleontiev Apr 13, 2017
792b4be
visual tweaks
aleontiev Apr 27, 2017
1d42e8f
..
aleontiev May 8, 2017
fef7cf3
rename directory.html -> root.html
aleontiev May 8, 2017
49c4958
fix is_root logic
aleontiev May 8, 2017
0bc9dab
add get breadcrumbs / renderer
aleontiev May 8, 2017
5221a57
request.path
aleontiev May 8, 2017
ce6b05e
response status code to prevent failure on error pages
aleontiev May 8, 2017
3494536
add ROOT_REQUIRES_AUTHENTICATION
aleontiev May 8, 2017
77a2bf5
fix as_id_to_name with uuid
aleontiev May 8, 2017
5613c7c
only show active routes in root view
aleontiev May 8, 2017
3672448
is_prefix_of
aleontiev May 8, 2017
75170e9
get_url no request
aleontiev May 8, 2017
4d1e163
print
aleontiev May 8, 2017
b8e8dee
WIP breadcrumbs
aleontiev May 9, 2017
ada9e78
Merge branch 'master' of github.com:AltSchool/dynamic-rest into integ…
aleontiev May 9, 2017
76b2433
respect serializer field ordering, respect http_method_names in admin…
aleontiev May 18, 2017
c58a093
Merge branch 'integration/admin-view' of github.com:AltSchool/dynamic…
aleontiev May 18, 2017
3e6f26f
Merge branch 'master' of github.com:AltSchool/dynamic-rest into integ…
aleontiev Aug 31, 2017
2da8b4a
Merge branch 'integration/admin-view' of github.com:AltSchool/dynamic…
aleontiev Aug 31, 2017
304e765
better support for nested source -- nested updates/creates/filters
aleontiev Sep 1, 2017
6a42075
better generic error handling + relationships
aleontiev Sep 3, 2017
d582d84
fix get model field
aleontiev Sep 3, 2017
f63e760
spike on CSS
aleontiev Sep 5, 2017
52fa899
add custom body
aleontiev Sep 6, 2017
bd6ceb3
stackables
aleontiev Sep 7, 2017
0038ed1
..
aleontiev Sep 7, 2017
68a0296
..
aleontiev Sep 8, 2017
bd59684
..
aleontiev Sep 8, 2017
bc5de10
..
aleontiev Sep 8, 2017
cd6d561
choices
aleontiev Sep 8, 2017
70c94a8
sd
aleontiev Sep 8, 2017
4d13e9e
choices field processing/dynamic value with classes
aleontiev Sep 8, 2017
a6d0443
get_class WIP
aleontiev Sep 8, 2017
ffbb477
..
aleontiev Sep 10, 2017
1b33e82
smaller width
aleontiev Sep 11, 2017
9809908
add alert, modal styling
aleontiev Sep 11, 2017
0686aa6
..
aleontiev Sep 11, 2017
f5980cb
..
aleontiev Sep 11, 2017
0da5e09
fix class for search
aleontiev Sep 11, 2017
e7e3258
hide those pages
aleontiev Sep 11, 2017
633d4f0
better pagination
aleontiev Sep 12, 2017
bc1f8de
..
aleontiev Sep 12, 2017
e56fd1a
add Dynamic*Fields
aleontiev Sep 13, 2017
c107d0c
rename natural_key -> name_field
aleontiev Sep 13, 2017
aade1b9
allowClear on select2
aleontiev Sep 13, 2017
9fac917
..
aleontiev Sep 13, 2017
ede1e5c
..
aleontiev Sep 13, 2017
c8491d8
fix name field
aleontiev Sep 13, 2017
084b64a
remove print
aleontiev Sep 14, 2017
1e8372c
early drf compat
aleontiev Sep 14, 2017
ce3092b
refactor rewrite
aleontiev Sep 15, 2017
d8ff5b3
refactor/shorten
aleontiev Sep 15, 2017
38ad948
use super() instead of object to call __new__ super
aleontiev Sep 15, 2017
fcb1b72
super(Meta, cls)
aleontiev Sep 15, 2017
0d80037
fix call to super
aleontiev Sep 15, 2017
b7b5820
change meta superclass
aleontiev Sep 15, 2017
5e3ed75
drop py33
aleontiev Sep 15, 2017
0e5f2d3
no test sugar
aleontiev Sep 15, 2017
5edddbb
..
aleontiev Sep 15, 2017
b85d702
3.3.6
aleontiev Sep 15, 2017
e3c6ea9
add dj.yml and fix tox invocation
aleontiev Sep 15, 2017
4610db5
use latest minor versions
aleontiev Sep 15, 2017
cfe282b
add CHANGELOG
aleontiev Sep 15, 2017
9227cc7
remove 3.3
aleontiev Sep 15, 2017
59a808a
fix meta
aleontiev Sep 15, 2017
c2acc0d
docs, rename rewrite -> resolve
aleontiev Sep 15, 2017
d76b232
clearer exceptions
aleontiev Sep 15, 2017
8a8fdc2
improve docs and UI
aleontiev Sep 15, 2017
650ab0f
fix carserializer name field
aleontiev Sep 15, 2017
27677fe
..
aleontiev Sep 15, 2017
6f417cd
fix sorting filter exception
aleontiev Sep 16, 2017
45e4f37
add needs_prefetch
aleontiev Sep 19, 2017
e5be6af
remove is_admin, change to gui (passed-in from view)
aleontiev Sep 19, 2017
6020e4e
..
aleontiev Sep 19, 2017
210ffa0
improve list field labeling
aleontiev Sep 19, 2017
794e03f
add labels and help text tooltips
aleontiev Sep 19, 2017
1873b61
..
aleontiev Sep 20, 2017
6230cc2
allowClear fix for many
aleontiev Sep 20, 2017
83fee9d
e.args[0]
aleontiev Sep 20, 2017
5c7e033
error
aleontiev Sep 21, 2017
c07feda
fix view
aleontiev Sep 21, 2017
b707e7a
remove unused variable, allow API exceptions to pass through serializ…
aleontiev Sep 21, 2017
c42fcff
remove fitlers
aleontiev Sep 21, 2017
4c95095
..
aleontiev Sep 22, 2017
781d0af
remove print
aleontiev Sep 22, 2017
bc09b1d
use field.get_related for magic
aleontiev Sep 25, 2017
d9aa86e
..
aleontiev Sep 27, 2017
181779c
fix related filtering
aleontiev Sep 28, 2017
7a08130
use query name
aleontiev Sep 28, 2017
b6a67d8
fix rel case
aleontiev Sep 28, 2017
d0901bb
add changelog reference + post/put support for ViewSetTestCase
aleontiev Sep 28, 2017
ce9b90b
add docs
aleontiev Sep 28, 2017
6148a4f
update changelog
aleontiev Sep 28, 2017
b4a61de
changelog format
aleontiev Sep 28, 2017
90b7055
better CL format
aleontiev Sep 28, 2017
9ae19ca
add missing `
aleontiev Sep 28, 2017
4869d4d
add **
aleontiev Sep 28, 2017
49ddee8
readme + change blueprint
aleontiev Sep 29, 2017
285cf81
update benchmarks
aleontiev Sep 29, 2017
ef35175
import from compat
aleontiev Sep 29, 2017
c75498c
fix as_hyperlink
aleontiev Sep 29, 2017
d75c38a
update readme
aleontiev Sep 29, 2017
7ceac0c
README
aleontiev Sep 29, 2017
c1302fd
add disclaimer
aleontiev Sep 29, 2017
e88d2e5
change benchmarks
aleontiev Sep 29, 2017
1e9b281
readme
aleontiev Sep 29, 2017
242740d
change integration test cond
aleontiev Sep 29, 2017
b0dfcda
remove vertical/
aleontiev Sep 29, 2017
2c11cac
README
aleontiev Sep 29, 2017
307d68a
remove browsable API test for user view
aleontiev Sep 29, 2017
f5ac480
better test view
aleontiev Sep 29, 2017
324b85c
deepcopy
aleontiev Sep 29, 2017
882b813
WIP 3.1/3.2 admin renderer
aleontiev Sep 29, 2017
ce81975
change DHTMLFR
aleontiev Sep 29, 2017
c0f429b
make is_superuser, not is_staff
aleontiev Oct 3, 2017
e50beca
fix tests
aleontiev Oct 4, 2017
adee8ae
invalid PK fix
aleontiev Oct 4, 2017
508301d
..
aleontiev Oct 5, 2017
955a78c
add DCreatorField
aleontiev Oct 5, 2017
2c30b25
Merge branch 'integration/admin-view'
aleontiev Oct 10, 2017
865f437
require < 3.6.4 (breaking change)
aleontiev Oct 10, 2017
1eba4b6
;
aleontiev Oct 10, 2017
87e5c56
..
aleontiev Oct 10, 2017
b7d86e3
..
aleontiev Oct 11, 2017
be68d37
..
aleontiev Oct 13, 2017
c2ce5c1
..
aleontiev Oct 17, 2017
85dc6e6
..
aleontiev Oct 19, 2017
5415e10
..
aleontiev Oct 19, 2017
4c39477
..
aleontiev Oct 20, 2017
e03decc
..
aleontiev Oct 23, 2017
151f724
..
aleontiev Oct 23, 2017
5a311a1
!
aleontiev Oct 23, 2017
a8aab6b
..
aleontiev Oct 24, 2017
5ab2d2f
....
aleontiev Oct 24, 2017
c86bc2a
as;da
aleontiev Oct 24, 2017
fb9cb43
..asdll
aleontiev Oct 24, 2017
6f6d359
sdasd
aleontiev Oct 25, 2017
7e347a9
dont try to set required/null on GFK
aleontiev Nov 2, 2017
dfaac52
update
aleontiev Dec 14, 2017
0c73acc
Merge branch 'master' of github.com:aleontiev/dynamic-rest
aleontiev Dec 14, 2017
ca61156
permissions baby
aleontiev Dec 16, 2017
76d6b4d
remove post ..
aleontiev Dec 16, 2017
b11bc8b
..
aleontiev Dec 16, 2017
fbaaf37
..
aleontiev Dec 16, 2017
f5f5626
tmeplates, permissions
aleontiev Dec 17, 2017
925e79c
support run validation / setter override
aleontiev Dec 17, 2017
73dc0c4
admin renderer - sorted fields
aleontiev Dec 24, 2017
fec1580
model_field
aleontiev Dec 24, 2017
b80d00d
fix get_model_field
aleontiev Dec 24, 2017
c1a02c6
..
aleontiev Dec 24, 2017
e93d2e6
landscape op
aleontiev Dec 24, 2017
c0764bb
..
aleontiev Dec 24, 2017
22f737a
..
aleontiev Dec 24, 2017
a0c6743
improve directory
aleontiev Dec 28, 2017
38e66a0
nicer icons
aleontiev Dec 28, 2017
b60f52e
..
aleontiev Dec 28, 2017
d3b42e8
..
aleontiev Dec 28, 2017
cb13139
back UI
aleontiev Dec 28, 2017
321ee57
beast filters
aleontiev Dec 29, 2017
749a513
fix
aleontiev Dec 29, 2017
52533b6
add support for create_related
aleontiev Jan 20, 2018
328c90f
fix array post params issue in test.py
aleontiev Jan 31, 2018
ee5ffde
..
aleontiev Mar 7, 2018
410fce0
..
aleontiev Mar 7, 2018
5a6df17
fallback in relation getter
aleontiev Mar 22, 2018
b202c63
add DynamicFileField with admin render support
aleontiev Mar 23, 2018
09ed3f1
fix HTML bug in DynamicFileField
aleontiev Mar 23, 2018
0e16bd7
add only_update option
aleontiev Mar 30, 2018
b0addb3
WIP
aleontiev Mar 31, 2018
ff1d9c4
only fields merge
aleontiev Mar 31, 2018
213345a
improve UI around create related
aleontiev Mar 31, 2018
4220530
support callable permissions spec + write_fields
aleontiev May 5, 2018
afc66c7
fix callable parsing
aleontiev May 6, 2018
a5eaa3c
deal with list-type specs (write fields)
aleontiev May 7, 2018
d4635f2
fix spec check
aleontiev May 7, 2018
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
*.pyc

.pytest_cache/
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
157 changes: 157 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# 2.0.0
Major release of DREST that includes core API-ORM translation improvements and a robust admin renderer. Compatability with 1.x is likely but not guaranteed, many private APIs have changed, some setting defaults have changed.

## Boilerplate

- Added integration with [dj](https://github.com/aleontiev/dj), including an `api` blueprint that can be used to bootstrap a new view/serializer:

```
dj add dynamic-rest
dj generate model product
dj generate api v0 product
```

## Fields

- `dynamic_rest.fields.DynamicRelationField`
- New initialization arguments: `getter` and `setter`
- Allows for custom relationship getting and setting.
This can be useful for simplifying complex "through" relations.

- Argument change: `serializer_class` is now optional
- `DynamicRelationField` will attempt to infer `serializer_class` from the
given source using `DynamicRouter.get_canonical_serializer`.

- New dynamic model fields: `dynamic_rest.fields.model`
- These fields add dynamic-value support to base DRF fields.
Dynamic values are values that can contain metadata used
by higher-level renderers (admin), such as styling directives.
At a lower-level (JSON), only the base value is rendered.
See `dynamic_rest.fields.DynamicChoicesField`.

## Serializers

- New setting: `ENABLE_SELF_LINKS`
- When enabled, links in representation will include reference to the current resource.
- Default is True.

- New serializer fields, see `dynamic_rest.fields.model`
- These fields extend the base DRF fields with dynamic value behavior.

- New serializer method: `get_url`
- Returns a URL to the serializer's collection or detail endpoint,
dependening on whether a PK is passed in.

- The URL key can be injected into the serializer by the router when
the serializer's view is registered. If not, this method will fallback
to `DynamicRouter.get_canonical_url`.

- New serializer method: `get_field`
- Returns a serializer field by name. Can also pass in "pk" as shorthand

- New serializer method: `resolve`
- Provides a consistent way to resolve an API-field
into a chain of model fields. Returns a model field list
and serializer field list.

- For example, consider the API field `creator.location_name`
on a `BlogSerializer` and underlying model path
`user.location.name` starting from the `Blog` model.
`BlogSerializer.resolve("creator.location_name")`
will return two paths of model and serializer fields necessary
to "reach" the field from the serializer.

```
[
("user", blog.user),
("location", user.location),
("name", location.name)
],
[
("creator", DynamicRelationField("UserSerializer", source="user")),
("location_name", DynamicCharField(source="location.name"))
]
```

- The two lists do not necessarily contain the same number of elements
because API fields can reference nested model fields.

- Calling resolve on a method field (`source == '*'`) will cause an exception.

- New serializer functionality: **nested updates**
- DREST serializers will now attempt to properly handle
nested-source fields during updates.

- For example, if there is a user with related `profile`,
a `UserSerializer` for the user can support updates
to the related profile phone by creating a field with
the nested source "profile.phone". Updates to the phone field
will be set on the profile object, which is then saved.

- If related objects do not exist, the serializer will attempt
to craete it using the fields in the request.
Multiple fields on a related model can be mapped.

## Views

- Fixed `sort[]` behavior around rewrites
- API-name to model-name rewrites are now properly handled by `sort[]`.

- New views: `dynamic_rest.login` and `dynamic_rest.logout`
- Wraps `django.contrib.auth.views` login and logout
using the DREST admin login template.

## Routers

- Renamed option: `ROOT_VIEW_NAME` renamed to `API_NAME`
- Human-friendly name of the API.

- New option: `API_DESCRIPTION`
- Human-friendly description of the API.

- New option: `API_ROOT_SECURE`
- If enabled, the root view will redirect if the user is not authenticated.
- Default is False.

## Renderers

- New renderer: `dynamic_rest.renderers.DynamicAdminRenderer`
- Extends `rest_framework.renderers.AdminRenderer`, adding a
new, responsively designed admin UI that integrates with DREST filters
and relationships.

- Serializers from 1.x should work as expected, but are recommended to set
the following configuration options in their `Meta` class to support an
ideal experience.
- `name_field`: a human-friendly field name for records
- defaults to the model PK
- used for relationship lookup and representation
- e.g. `"name"`
- `search_key`: a filter key to search against to find records of this resource
- defaults to None
- used for search
- e.g: `"filter{name.icontains}"`
- `list_fields`: a list of fields to display within long lists
- defaults to all fields
- used for displaying the list view
- e.g. `["name", "description"]`
- `description`: a description of the resource
- e.g: "The Build resource represents a backend build."

- New option: `ADMIN_LOGIN_URL`
- The login URL to use within the admin UI.

- New option: `ADMIN_LOGOUT_URL`
- The logout URL to use within the admin UI.

- New option: `ADMIN_TEMPLATE`
- Template file name for the admin view.
- Defaults to "dynamic_rest/admin.html"
- Customizations are possible by settings `ADMIN_TEMPLATE` to an
application-specific template, e.g. "app/admin.html".
- Common blocks to override: `bootstrap_css`, `brand`.
- The base UI is implemented in and requires Bootstrap 4.

- New option: `ADMIN_LOGIN_TEMPLATE`
- Template file name for the admin login view.
- Defaults to "dynamic_rest/login.html"
Loading