Skip to content

Commit 01063a9

Browse files
committed
Merge branch 'master' of github.com:swp-berlin/webmonitor into staging
2 parents dc31b4c + 79b8098 commit 01063a9

File tree

8 files changed

+54
-32
lines changed

8 files changed

+54
-32
lines changed

docs/usage/search.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ The search interface uses the ElasticSearch index to search through all publicat
66

77
The following fields are indexed:
88

9-
| Field | Type |
10-
|-------------------|-----------------|
11-
| id | Integer |
12-
| thinktank_id | Integer |
13-
| title | String |
14-
| subtitle | String |
15-
| ris_type | String |
16-
| authors | List[String] |
17-
| abstract | String |
18-
| publication_date | Date |
19-
| last_access | String/Datetime |
20-
| url | String |
21-
| pdf_url | String |
22-
| pdf_pages | Integer |
23-
| doi | String |
24-
| isbn | String |
25-
| tags | List[String] |
26-
| categories | List[String] |
27-
| created | String/Datetime |
28-
| thinktank.name | String |
9+
| Field | Type |
10+
|------------------|-----------------|
11+
| id | Integer |
12+
| thinktank.id | Integer |
13+
| title | String |
14+
| subtitle | String |
15+
| ris_type | String |
16+
| authors | List[String] |
17+
| abstract | String |
18+
| publication_date | Date |
19+
| last_access | String/Datetime |
20+
| url | String |
21+
| pdf_url | String |
22+
| pdf_pages | Integer |
23+
| doi | String |
24+
| isbn | String |
25+
| tags | List[String] |
26+
| categories | List[String] |
27+
| created | String/Datetime |
28+
| thinktank.name | String |
2929

3030
Any word without a field qualifier is searched in the fields 'title', 'subtitle', 'abstract', 'authors', 'isbn' and 'tags'.
3131

swp/api/serializers/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class PoolField(PrimaryKeyRelatedField):
1212

1313
def get_queryset(self):
14-
return Pool.objects.can_manage(self.context.get('request').user)
14+
return Pool.objects.annotate_can_manage(self.context.get('request').user)
1515

1616
def use_pk_only_optimization(self):
1717
return False

swp/api/viewsets/monitor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class MonitorViewSet(ModelViewSet):
4343

4444
def get_queryset(self):
4545
return ModelViewSet.get_queryset(self).prefetch_related(
46-
Prefetch('pool', Pool.objects.can_manage(self.request.user)),
46+
Prefetch('pool', Pool.objects.annotate_can_manage(self.request.user)),
4747
)
4848

4949
def get_serializer_class(self):

swp/assets/scripts/components/Fetch/index.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ import Query from './Query';
33
import Result from './Result';
44
import Loading from './Loading';
55
import ChoicesQuery from './ChoicesQuery';
6+
import ClientError from './ClientError';
67
import NetworkError from './NetworkError';
78

8-
export {Form, Query, Result, Loading, ChoicesQuery, NetworkError, useMutationForm, useMutationResult};
9+
export {
10+
Form,
11+
Query,
12+
Result,
13+
Loading,
14+
ChoicesQuery,
15+
ClientError,
16+
NetworkError,
17+
useMutationForm,
18+
useMutationResult,
19+
};
920

1021
export default {
1122
Form,

swp/assets/scripts/components/monitor/MonitorEdit.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ import _ from 'utils/i18n';
44

55
import {useQuery} from 'hooks/query';
66

7-
import Page from 'components/Page';
87
import {Result} from 'components/Fetch';
98

10-
import MonitorForm from './MonitorForm';
119
import {useMonitorsBreadcrumb} from './MonitorList';
1210
import {useMonitorBreadcrumb} from './MonitorDetail';
1311

12+
import MonitorEditPage from './MonitorEditPage';
13+
import MonitorForm from './MonitorForm';
14+
1415
const Title = _('Edit Monitor');
1516
const SubmitLabel = _('Save');
1617
const SuccessMessage = _('Successfully changed monitor');
@@ -26,7 +27,7 @@ const MonitorEdit = props => {
2627
return (
2728
<Result result={result}>
2829
{monitor => (
29-
<Page title={Title}>
30+
<MonitorEditPage pool={monitor.pool} title={Title}>
3031
<MonitorForm
3132
endpoint={endpoint}
3233
method="PATCH"
@@ -36,7 +37,7 @@ const MonitorEdit = props => {
3637
data={monitor}
3738
{...props}
3839
/>
39-
</Page>
40+
</MonitorEditPage>
4041
)}
4142
</Result>
4243
);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {ClientError} from 'components/Fetch';
2+
import Page from 'components/Page';
3+
4+
const MonitorEditPage = ({pool: {can_edit: canEdit}, children, ...props}) => (
5+
<Page {...props}>
6+
{canEdit ? children : <ClientError status={403} />}
7+
</Page>
8+
);
9+
10+
export default MonitorEditPage;

swp/assets/scripts/components/monitor/MonitorQueryEdit/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import _ from 'utils/i18n';
55
import {useQuery} from 'hooks/query';
66

77
import {Result} from 'components/Fetch';
8-
import Page from 'components/Page';
98

109
import {useMonitorsBreadcrumb} from '../MonitorList';
1110
import {useMonitorBreadcrumb} from '../MonitorDetail';
1211

12+
import MonitorEditPage from '../MonitorEditPage';
1313
import MonitorQueryEditForm from './MonitorQueryEditForm';
1414

1515
const Title = _('Edit Query');
@@ -25,9 +25,9 @@ const MonitorQueryEdit = () => {
2525
return (
2626
<Result result={result}>
2727
{monitor => (
28-
<Page title={Title}>
28+
<MonitorEditPage pool={monitor.pool} title={Title}>
2929
<MonitorQueryEditForm endpoint={endpoint} monitor={monitor} />
30-
</Page>
30+
</MonitorEditPage>
3131
)}
3232
</Result>
3333
);

swp/utils/scraping/browser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121

2222
@contextmanager
23-
def tempoary_user_dir():
23+
def temporary_user_dir():
2424
with maketempdir() as temp_dir:
2525
pref_file_path = temp_dir / 'Default' / 'Preferences'
2626

@@ -42,7 +42,7 @@ async def open_browser(*args, **kwargs) -> ContextManager[Browser]:
4242
kwargs.setdefault('devtools', True)
4343

4444
async with async_playwright() as playwright:
45-
with tempoary_user_dir() as user_dir:
45+
with temporary_user_dir() as user_dir:
4646
browser = await playwright.chromium.launch_persistent_context(
4747
user_dir,
4848
*args,

0 commit comments

Comments
 (0)