mirror of
https://github.com/ascribe/onion.git
synced 2024-12-22 17:33:14 +01:00
Merged in AD-44-in-piece-detail-support-public-not (pull request #2)
CSRF and acl edit tweaks
This commit is contained in:
commit
8846a11e00
@ -27,16 +27,19 @@ let PieceExtraDataForm = React.createClass({
|
||||
},
|
||||
|
||||
renderForm() {
|
||||
|
||||
let defaultValue = this.props.editions[0].extra_data[this.props.name] || '';
|
||||
if (defaultValue.length === 0 && ~this.props.editable){
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<form role="form" key={this.props.name}>
|
||||
<h5>{this.props.title}</h5>
|
||||
<InputTextAreaToggable
|
||||
ref={this.props.name}
|
||||
className="form-control"
|
||||
defaultValue={this.props.editions[0].extra_data[this.props.name]}
|
||||
defaultValue={defaultValue}
|
||||
rows={3}
|
||||
editable={true}
|
||||
editable={this.props.editable}
|
||||
required=""
|
||||
onSubmit={this.submit}
|
||||
/>
|
||||
|
@ -2,6 +2,9 @@
|
||||
|
||||
import React from 'react';
|
||||
|
||||
import UserActions from '../actions/user_actions';
|
||||
import UserStore from '../stores/user_store';
|
||||
|
||||
import MediaPlayer from './ascribe_media/media_player';
|
||||
|
||||
import CollapsibleMixin from 'react-bootstrap/lib/CollapsibleMixin';
|
||||
@ -31,6 +34,23 @@ let Edition = React.createClass({
|
||||
loadEdition: React.PropTypes.func
|
||||
},
|
||||
|
||||
getInitialState() {
|
||||
return UserStore.getState();
|
||||
},
|
||||
|
||||
componentDidMount() {
|
||||
UserStore.listen(this.onChange);
|
||||
UserActions.fetchCurrentUser();
|
||||
},
|
||||
|
||||
componentWillUnmount() {
|
||||
UserStore.unlisten(this.onChange);
|
||||
},
|
||||
|
||||
onChange(state) {
|
||||
this.setState(state);
|
||||
},
|
||||
|
||||
render() {
|
||||
let thumbnail = this.props.edition.thumbnail;
|
||||
let mimetype = this.props.edition.digital_work.mime;
|
||||
@ -71,8 +91,10 @@ let Edition = React.createClass({
|
||||
edition={this.props.edition} />
|
||||
<CollapsibleEditionDetails
|
||||
title="Personal Note"
|
||||
show={this.state.currentUser && true || false}
|
||||
iconName="pencil">
|
||||
<EditionPersonalNote
|
||||
currentUser={this.state.currentUser}
|
||||
handleSuccess={this.props.loadEdition}
|
||||
edition={this.props.edition}/>
|
||||
</CollapsibleEditionDetails>
|
||||
@ -160,7 +182,7 @@ let EditionSummary = React.createClass({
|
||||
status = <EditionDetailProperty label="STATUS" value={ this.props.edition.status.join().replace(/_/, ' ') } />;
|
||||
}
|
||||
let actions = null;
|
||||
if (this.props.edition.request_action){
|
||||
if (this.props.edition.request_action && this.props.edition.request_action.length > 0){
|
||||
actions = (
|
||||
<RequestActionForm
|
||||
editions={ [this.props.edition] }
|
||||
@ -372,6 +394,7 @@ let EditionFurtherDetails = React.createClass({
|
||||
},
|
||||
|
||||
render() {
|
||||
let editable = this.props.edition.acl.indexOf('edit') > -1;
|
||||
return (
|
||||
<Row>
|
||||
<Col md={12} className="ascribe-edition-personal-note">
|
||||
@ -379,16 +402,19 @@ let EditionFurtherDetails = React.createClass({
|
||||
name='artist_contact_info'
|
||||
title='Artist Contact Info'
|
||||
handleSuccess={this.showNotification}
|
||||
editable={editable}
|
||||
editions={[this.props.edition]} />
|
||||
<PieceExtraDataForm
|
||||
name='display_instructions'
|
||||
title='Display Instructions'
|
||||
handleSuccess={this.showNotification}
|
||||
editable={editable}
|
||||
editions={[this.props.edition]} />
|
||||
<PieceExtraDataForm
|
||||
name='technology_details'
|
||||
title='Technology Details'
|
||||
handleSuccess={this.showNotification}
|
||||
editable={editable}
|
||||
editions={[this.props.edition]} />
|
||||
</Col>
|
||||
</Row>
|
||||
|
@ -24,6 +24,7 @@ import { getLangText } from '../utils/lang_utils';
|
||||
let Link = Router.Link;
|
||||
|
||||
let Header = React.createClass({
|
||||
mixins: [Router.Navigation],
|
||||
|
||||
getInitialState() {
|
||||
return UserStore.getState();
|
||||
@ -43,8 +44,7 @@ let Header = React.createClass({
|
||||
},
|
||||
|
||||
refreshData(){
|
||||
UserActions.fetchCurrentUser();
|
||||
PieceListActions.fetchPieceList(1, 10);
|
||||
location.reload();
|
||||
},
|
||||
render() {
|
||||
let account = null;
|
||||
|
@ -62,3 +62,11 @@ export function status(response) {
|
||||
}
|
||||
throw new Error(response.json());
|
||||
}
|
||||
|
||||
export function getCookie(name) {
|
||||
let value = '; ' + document.cookie;
|
||||
let parts = value.split('; ' + name + '=');
|
||||
if (parts.length === 2) {
|
||||
return parts.pop().split(';').shift();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
import { argsToQueryParams } from '../utils/fetch_api_utils';
|
||||
import { argsToQueryParams, getCookie } from '../utils/fetch_api_utils';
|
||||
|
||||
|
||||
class UrlMapError extends Error {}
|
||||
@ -76,6 +76,7 @@ class Requests {
|
||||
request(verb, url, options) {
|
||||
options = options || {};
|
||||
let merged = this._merge(this.httpOptions, options);
|
||||
this.httpOptions.headers['X-CSRFToken'] = getCookie('csrftoken');
|
||||
merged.method = verb;
|
||||
return fetch(url, merged)
|
||||
.then(this.unpackResponse)
|
||||
|
Loading…
Reference in New Issue
Block a user