1
0
mirror of https://github.com/ascribe/onion.git synced 2024-11-15 09:35:10 +01:00

csrf subdomain

This commit is contained in:
ddejongh 2015-06-16 14:49:00 +02:00
parent 1ecd579718
commit 9cf060fdc4
4 changed files with 82 additions and 4 deletions

View File

@ -0,0 +1,43 @@
'use strict';
import React from 'react';
import apiUrls from '../../constants/api_urls';
import FormMixin from '../../mixins/form_mixin';
import InputTextAreaToggable from './input_textarea_toggable';
let EditionNoteForm = React.createClass({
mixins: [FormMixin],
url() {
return apiUrls.note_edition;
},
getFormData() {
return {
bitcoin_id: this.getBitcoinIds().join(),
note: this.refs.personalNote.state.value
};
},
renderForm() {
return (
<form id="personal_note_content" role="form" key="personal_note_content">
<InputTextAreaToggable
ref="personalNote"
className="form-control"
defaultValue={this.props.editions[0].note_from_user}
rows={3}
editable={this.props.editable}
required=""
onSubmit={this.submit}
/>
</form>
);
}
});
export default EditionNoteForm;

View File

@ -31,7 +31,7 @@ let PersonalNoteForm = React.createClass({
className="form-control" className="form-control"
defaultValue={this.props.editions[0].note_from_user} defaultValue={this.props.editions[0].note_from_user}
rows={3} rows={3}
editable={true} editable={this.props.editable}
required="" required=""
onSubmit={this.submit} onSubmit={this.submit}
/> />

View File

@ -14,6 +14,8 @@ import Button from 'react-bootstrap/lib/Button';
import Glyphicon from 'react-bootstrap/lib/Glyphicon'; import Glyphicon from 'react-bootstrap/lib/Glyphicon';
import PersonalNoteForm from './ascribe_forms/form_note_personal'; import PersonalNoteForm from './ascribe_forms/form_note_personal';
import EditionNoteForm from './ascribe_forms/form_note_edition';
import PieceExtraDataForm from './ascribe_forms/form_piece_extradata'; import PieceExtraDataForm from './ascribe_forms/form_piece_extradata';
import RequestActionForm from './ascribe_forms/form_request_action'; import RequestActionForm from './ascribe_forms/form_request_action';
@ -90,14 +92,21 @@ let Edition = React.createClass({
<EditionSummary <EditionSummary
edition={this.props.edition} /> edition={this.props.edition} />
<CollapsibleEditionDetails <CollapsibleEditionDetails
title="Personal Note" title="Personal Note (private)"
show={this.state.currentUser && true || false} show={this.state.currentUser.username && true || false}
iconName="pencil"> iconName="pencil">
<EditionPersonalNote <EditionPersonalNote
currentUser={this.state.currentUser} currentUser={this.state.currentUser}
handleSuccess={this.props.loadEdition} handleSuccess={this.props.loadEdition}
edition={this.props.edition}/> edition={this.props.edition}/>
</CollapsibleEditionDetails> </CollapsibleEditionDetails>
<CollapsibleEditionDetails
title="Edition Note (public)"
iconName="pencil">
<EditionPublicEditionNote
handleSuccess={this.props.loadEdition}
edition={this.props.edition}/>
</CollapsibleEditionDetails>
<CollapsibleEditionDetails <CollapsibleEditionDetails
title="Further Details"> title="Further Details">
<EditionFurtherDetails <EditionFurtherDetails
@ -364,7 +373,7 @@ let EditionPersonalNote = React.createClass({
}, },
showNotification(){ showNotification(){
this.props.handleSuccess(); this.props.handleSuccess();
let notification = new GlobalNotificationModel('Note saved', 'success'); let notification = new GlobalNotificationModel('Private note saved', 'success');
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
}, },
render() { render() {
@ -372,6 +381,7 @@ let EditionPersonalNote = React.createClass({
<Row> <Row>
<Col md={12} className="ascribe-edition-personal-note"> <Col md={12} className="ascribe-edition-personal-note">
<PersonalNoteForm <PersonalNoteForm
editable={true}
handleSuccess={this.showNotification} handleSuccess={this.showNotification}
editions={[this.props.edition]} /> editions={[this.props.edition]} />
</Col> </Col>
@ -381,6 +391,30 @@ let EditionPersonalNote = React.createClass({
}); });
let EditionPublicEditionNote = React.createClass({
propTypes: {
edition: React.PropTypes.object,
handleSuccess: React.PropTypes.func
},
showNotification(){
this.props.handleSuccess();
let notification = new GlobalNotificationModel('Public note saved', 'success');
GlobalNotificationActions.appendGlobalNotification(notification);
},
render() {
return (
<Row>
<Col md={12} className="ascribe-edition-personal-note">
<EditionNoteForm
editable={this.props.edition.acl.indexOf('edit') > -1}
handleSuccess={this.showNotification}
editions={[this.props.edition]} />
</Col>
</Row>
);
}
});
let EditionFurtherDetails = React.createClass({ let EditionFurtherDetails = React.createClass({
propTypes: { propTypes: {

View File

@ -8,6 +8,7 @@ let apiUrls = {
'edition_remove_from_collection': AppConstants.apiEndpoint + 'ownership/shares/${edition_id}/', 'edition_remove_from_collection': AppConstants.apiEndpoint + 'ownership/shares/${edition_id}/',
'editions_list': AppConstants.apiEndpoint + 'pieces/${piece_id}/editions/', 'editions_list': AppConstants.apiEndpoint + 'pieces/${piece_id}/editions/',
'note_notes': AppConstants.apiEndpoint + 'note/notes/', 'note_notes': AppConstants.apiEndpoint + 'note/notes/',
'note_edition': AppConstants.apiEndpoint + 'note/edition_notes/',
'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/', 'ownership_consigns': AppConstants.apiEndpoint + 'ownership/consigns/',
'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/', 'ownership_consigns_confirm': AppConstants.apiEndpoint + 'ownership/consigns/confirm/',
'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/', 'ownership_consigns_deny': AppConstants.apiEndpoint + 'ownership/consigns/deny/',