Skip to content

Commit

Permalink
#133 Tutor can only see what they uploaded, not the others
Browse files Browse the repository at this point in the history
  • Loading branch information
kasthurie committed Jan 17, 2020
1 parent 653fa21 commit 2ec9ab2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions tutify/backend/controllers/uploaded_files.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ var mongoose = require('mongoose');

// This method fetches the latest uploaded document.
exports.getLatestUpload = async function (req, res) {
UploadedFiles.find({},function(err,mostRecent){
UploadedFiles.find({adminTutor:req.session.userInfo._id},function(err,mostRecent){
return res.json({ success: true, recent: mostRecent });
}).sort({_id:-1}).limit(1);
}


// This method adds restriction information for uploaded documents.
exports.addUploadedFiles = async function (req, res) {
let uploaded_files = new UploadedFiles();
Expand Down
12 changes: 9 additions & 3 deletions tutify/src/components/Documents/UploadDocuments.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import TableHead from '@material-ui/core/TableHead';
import TableRow from '@material-ui/core/TableRow';
import Link from '@material-ui/core/Link';
import Paper from '@material-ui/core/Paper';
import Fab from "@material-ui/core/Fab";
import GetAppIcon from '@material-ui/icons/GetApp';


// Display a Ui for Tutors in order to be able to upload their documents
Expand All @@ -29,7 +31,7 @@ export class UploadDocuments extends Component {
course: "",
recentFileName: "",
recentUploadDate: "",
recentTutorUploadName: ""
recentFileLink: ""
}
this.fileChanged = this.fileChanged.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
Expand Down Expand Up @@ -65,7 +67,7 @@ export class UploadDocuments extends Component {
.then(recent => {
this.setState({ recentFileName: recent.recent[0].name,
recentUploadDate: (recent.recent[0].uploadDate).split("T")[0],
recentTutorUploadName: recent.recent[0].adminTutor
recentFileLink: recent.recent[0].link
});
})
.catch(err => console.log(err));
Expand Down Expand Up @@ -199,7 +201,11 @@ export class UploadDocuments extends Component {
<TableRow>
<TableCell>{this.state.recentUploadDate}</TableCell>
<TableCell>{this.state.recentFileName}</TableCell>
<TableCell align="right">{this.state.recentTutorUploadName}</TableCell>
<TableCell align="right">
<Fab type="button" variant="extended" aria-label="add" size="small" className={classes.courseButton} onClick={() => window.open(this.state.recentFileLink, "_blank")} >
<GetAppIcon fontSize="small"style={{ width: '22px', height: '22px' }} />
</Fab >
</TableCell>
</TableRow>
</TableBody>
</Table>
Expand Down

0 comments on commit 2ec9ab2

Please sign in to comment.