1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-23 01:39:36 +01:00

fineuploader session with cors

This commit is contained in:
diminator 2015-07-02 11:54:33 +02:00
parent 85347a8916
commit 18f3b51153
6 changed files with 65 additions and 23 deletions

View File

@ -110,8 +110,8 @@ let Form = React.createClass({
buttons = (
<div className="row" style={{margin: 0}}>
<p className="pull-right">
<Button className="ascribe-btn" type="submit">Save</Button>
<Button className="ascribe-btn" onClick={this.reset}>Cancel</Button>
<Button className="btn btn-default btn-sm ascribe-margin-1px" type="submit">SAVE</Button>
<Button className="btn btn-danger btn-delete btn-sm ascribe-margin-1px" onClick={this.reset}>CANCEL</Button>
</p>
</div>
);

View File

@ -555,6 +555,10 @@ let FileUploader = React.createClass({
},
params: {
'pk': this.props.edition.other_data ? this.props.edition.other_data.id : null
},
cors: {
expected: true,
sendCredentials: true
}
}}
areAssetsDownloadable={true}

View File

@ -15,6 +15,8 @@ import ApplicationStore from '../stores/application_store';
import GlobalNotificationModel from '../models/global_notification_model';
import GlobalNotificationActions from '../actions/global_notification_actions';
import ReactS3FineUploader from './ascribe_uploader/react_s3_fine_uploader';
import CollapsibleParagraph from './ascribe_collapsible/collapsible_paragraph';
import Form from './ascribe_forms/form';
import Property from './ascribe_forms/property';
@ -22,6 +24,7 @@ import Property from './ascribe_forms/property';
import apiUrls from '../constants/api_urls';
import AppConstants from '../constants/application_constants';
import { getCookie } from '../utils/fetch_api_utils';
let SettingsContainer = React.createClass({
mixins: [Router.Navigation],
@ -30,8 +33,11 @@ let SettingsContainer = React.createClass({
return (
<div>
<AccountSettings />
<BitcoinWalletSettings />
<APISettings />
<BitcoinWalletSettings />
<LoanContractSettings />
<br />
<br />
</div>
);
}
@ -172,19 +178,57 @@ let BitcoinWalletSettings = React.createClass({
}
});
let ContractSettings = React.createClass({
propTypes: {
currentUser: React.PropTypes.object
},
let LoanContractSettings = React.createClass({
render() {
return (
<div>
<div>Username: {this.props.currentUser.username}</div>
<div>Email: {this.props.currentUser.email}</div>
</div>
<CollapsibleParagraph
title="Loan Contract Settings"
show={true}
defaultExpanded={true}>
<FileUploader />
</CollapsibleParagraph>
);
}
});
let FileUploader = React.createClass({
propTypes: {
},
render() {
return (
<Form>
<Property
label="Contract file">
<ReactS3FineUploader
keyRoutine={{
url: AppConstants.serverUrl + 's3/key/',
fileClass: 'contract'
}}
createBlobRoutine={{
url: apiUrls.ownership_loans_contract
}}
validation={{
itemLimit: 100000,
sizeLimit: '10000000'
}}
session={{
endpoint: apiUrls.ownership_loans_contract,
customHeaders: {
'X-CSRFToken': getCookie('csrftoken')
},
cors: {
expected: true,
sendCredentials: true
}
}}
areAssetsDownloadable={true}
areAssetsEditable={true}/>
</Property>
<hr />
</Form>
);
}
});

View File

@ -23,6 +23,7 @@ let apiUrls = {
'ownership_loans': AppConstants.apiEndpoint + 'ownership/loans/',
'ownership_loans_confirm': AppConstants.apiEndpoint + 'ownership/loans/confirm/',
'ownership_loans_deny': AppConstants.apiEndpoint + 'ownership/loans/deny/',
'ownership_loans_contract': AppConstants.apiEndpoint + 'ownership/loans/contract/',
'ownership_shares': AppConstants.apiEndpoint + 'ownership/shares/',
'ownership_transfers': AppConstants.apiEndpoint + 'ownership/transfers/',
'ownership_transfers_withdraw': AppConstants.apiEndpoint + 'ownership/transfers/withdraw/',

View File

@ -1,7 +1,6 @@
'use strict';
import fetch from 'isomorphic-fetch';
import requests from '../utils/requests';
import AppConstants from '../constants/application_constants';
@ -11,13 +10,7 @@ let OwnershipFetcher = {
* If no arg is supplied, load the current user
*/
fetchLoanContract(email) {
return fetch(AppConstants.baseUrl + 'ownership/loans/contract/?loanee=' + email, {
headers: {
'Authorization': 'Basic ' + AppConstants.debugCredentialBase64
}
}).then(
(res) => res.json()
);
return requests.get(AppConstants.apiEndpoint + 'ownership/loans/contract/?loanee=' + email);
}
};

View File

@ -44,10 +44,10 @@ class Requests {
}
handleAPIError(json) {
if (!json.success) {
if (json.success === false) {
let error = new APIError();
error.json = json;
console.error(new Error('The \'success\' property is missing in the server\'s response.'));
//console.error(new Error('The \'success\' property is missing in the server\'s response.'));
throw error;
}
return json;