Skip to content

Commit

Permalink
Allow admin user to export CSV from frontend user dropdown
Browse files Browse the repository at this point in the history
It is better UX to have CSV download access via the front-end than to log into the django admin or remember a URL.

Refs #385
  • Loading branch information
fungjj92 committed Jan 23, 2019
1 parent 0fa7c4c commit dd41f79
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/icp/apps/beekeepers/js/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export function signUp(form) {
dispatch(setAuthState({
username: '',
authError: '',
isStaff: false,
userId: null,
userSurvey: null,
message: 'Please click the validation link in your email and then log in.',
Expand All @@ -179,6 +180,7 @@ export function signUp(form) {
dispatch(setAuthState({
username: '',
authError: error.response.data.errors[0],
isStaff: false,
userId: null,
userSurvey: null,
message: '',
Expand All @@ -199,6 +201,7 @@ export function login(form) {
username: data.username || '',
authError: '',
message: '',
isStaff: data.is_staff,
userId: data.id || null,
userSurvey: data.beekeeper_survey,
}));
Expand All @@ -208,6 +211,7 @@ export function login(form) {
dispatch(setAuthState({
username: '',
message: '',
isStaff: false,
authError: error.response.data.errors[0],
userId: null,
userSurvey: null,
Expand All @@ -222,6 +226,7 @@ export function logout() {
username: '',
authError: '',
message: '',
isStaff: false,
userId: null,
userSurvey: null,
}));
Expand All @@ -238,13 +243,15 @@ export function sendAuthLink(form, endpoint) {
username: '',
userId: null,
message: 'Check your email to reset your password or activate your account',
isStaff: false,
authError: '',
userSurvey: null,
}));
}).catch((error) => {
dispatch(setAuthState({
message: '',
authError: error.response.data.errors[0],
isStaff: false,
username: '',
userSurvey: null,
userId: null,
Expand All @@ -258,6 +265,7 @@ export function createUserSurvey(form) {
auth: {
username,
userId,
isStaff,
},
} = getState();

Expand All @@ -268,6 +276,7 @@ export function createUserSurvey(form) {
message: '',
authError: '',
userId,
isStaff,
userSurvey: data.beekeeper_survey,
}));
dispatch(closeUserSurveyModal());
Expand All @@ -279,6 +288,7 @@ export function createUserSurvey(form) {
username,
message: '',
authError: errorMsg,
isStaff,
userId,
userSurvey: null,
}));
Expand Down
6 changes: 5 additions & 1 deletion src/icp/apps/beekeepers/js/src/components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import { connect } from 'react-redux';
import { NavLink, withRouter } from 'react-router-dom';
import { func, string, bool } from 'prop-types';

import { openParticipateModal, openLoginModal, logout } from '../actions';
import {
openParticipateModal,
openLoginModal,
logout,
} from '../actions';

const Header = ({ dispatch, username, isStaff }) => {
const exportDataButton = isStaff
Expand Down
1 change: 1 addition & 0 deletions src/icp/apps/beekeepers/js/src/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const initialAuthState = {
userId: null,
authError: '',
message: '',
isStaff: false,
userSurvey: null,
};

Expand Down
5 changes: 5 additions & 0 deletions src/icp/apps/beekeepers/sass/06_components/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
}
}

&__link {
color: $color-grey-2;
text-decoration: none;
}

&__button {
padding: 0;
color: $color-grey-2;
Expand Down
2 changes: 2 additions & 0 deletions src/icp/apps/user/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def login(request):
'username': user.username,
'guest': False,
'id': user.id,
'is_staff': user.is_staff,
'beekeeper_survey': user_survey
}
else:
Expand Down Expand Up @@ -79,6 +80,7 @@ def login(request):
'result': 'success',
'username': user.username,
'guest': False,
'is_staff': user.is_staff,
'id': user.id,
'beekeeper_survey': user_survey
}
Expand Down

0 comments on commit dd41f79

Please sign in to comment.