Skip to content

Commit

Permalink
edit option for admins added
Browse files Browse the repository at this point in the history
  • Loading branch information
buildwithmalik committed Dec 7, 2020
1 parent a87e16b commit f472f89
Show file tree
Hide file tree
Showing 19 changed files with 690 additions and 44 deletions.
10 changes: 9 additions & 1 deletion contibuting.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ NOTE : FILENAME is the only thing that differs across Notes/Question Papers and
--> for question papers , FILENAME == notes.title [notes.year]
but then 2 papers may cause collision to title == year , and the collision will take care of adding #

--> for syllabus , FILENAME == "notes.sem + notes.branch" , so title configured accordingly
--> for syllabus , FILENAME == "notes.sem + notes.branch" , so title configured accordingly


--> If document models are updated to hold more information following logics need to be updated
- Edit View
- Upload Log
- Upload Screen to enter data
- The model itself
- The view where the document is being shown
2 changes: 2 additions & 0 deletions lib/app/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:FSOUNotes/ui/views/about_us/privacy_policy/terms_and_conditionvi
import 'package:FSOUNotes/ui/views/admin/admin_view.dart';
import 'package:FSOUNotes/ui/views/all_documents/all_documents_view.dart';
import 'package:FSOUNotes/ui/views/downloads/Downloads_view.dart';
import 'package:FSOUNotes/ui/views/edit/edit_view.dart';
import 'package:FSOUNotes/ui/views/home/home_view.dart';
import 'package:FSOUNotes/ui/views/intro/intro_view.dart';
import 'package:FSOUNotes/ui/views/links/links_view.dart';
Expand Down Expand Up @@ -45,4 +46,5 @@ class $Router {
TermsAndConditionView termsAndConditionView;
AdminView adminViewRoute;
WebViewWidget webViewWidgetRoute;
EditView editViewRoute;
}
35 changes: 35 additions & 0 deletions lib/app/router.gr.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions lib/enums/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,15 @@ static getConstantFromDoc(Document document){
case Document.Syllabus:
return Constants.syllabus;
break;
case Document.Links:
return Constants.links;
break;
case Document.Report:
return Constants.report;
break;
case Document.UploadLog:
return Constants.uploadLog;
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/models/link.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Link extends AbstractDocument{
Document path;
String uploader_id;

Link({this.subjectName, this.title, this.description, this.linkUrl, this.id, this.path});
Link({this.subjectName, this.title, this.description, this.linkUrl, this.id, this.path,this.uploader_id});


Link.fromData(Map<String,dynamic> data)
Expand Down
6 changes: 6 additions & 0 deletions lib/models/notes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ class Note extends AbstractDocument {
this.isDownloaded = false,
@required this.path,
this.votes,
this.GDriveID,
this.GDriveLink,
this.GDriveNotesFolderID,
this.firebaseId,
this.id,
this.uploader_id,
});

Note.fromData(Map<String, dynamic> data , String documentID) {
Expand Down
7 changes: 6 additions & 1 deletion lib/models/question_paper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:FSOUNotes/models/document.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:logger/logger.dart';
Logger log = getLogger("QuestionPaper");

class QuestionPaper extends AbstractDocument{
Logger log = getLogger("QuestionPaper");
String id;

//For question papers , the title is the year
Expand Down Expand Up @@ -46,6 +46,11 @@ class QuestionPaper extends AbstractDocument{
this.branch,
this.year,
@required this.type,
this.GDriveID,
this.GDriveLink,
this.GDriveQuestionPaperFolderID,
this.id,
this.uploader_id,
});


Expand Down
7 changes: 6 additions & 1 deletion lib/models/syllabus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import 'package:FSOUNotes/models/document.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:logger/logger.dart';
Logger log = getLogger("SyllabusModel");

class Syllabus extends AbstractDocument{
Logger log = getLogger("SyllabusModel");
String id;

//For Syllabus , the title is the year + branch
Expand Down Expand Up @@ -45,6 +45,11 @@ class Syllabus extends AbstractDocument{
this.semester,
this.year,
@required this.type,
this.GDriveID,
this.GDriveLink,
this.GDriveSyllabusFolderID,
this.id,
this.uploader_id,
});


Expand Down
17 changes: 15 additions & 2 deletions lib/services/funtional_services/firestore_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ class FirestoreService {
CollectionReference ref = _notesCollectionReference;
try {
if (note.id != null && note.id.length > 3) {
log.w("Document being deleted using ID");
log.w("Document being updated using ID");
if (note.id.length > 5) {
await ref.document(note.id).setData(note.toJson());
if (note.path == Document.Links){
Expand All @@ -556,7 +556,7 @@ class FirestoreService {
}
} else {
log.w(
"Document being deleted using url matching in firebase , may cause more reads");
"Document being updated using url matching in firebase , may cause more reads");
QuerySnapshot snapshot =
await ref.where("title", isEqualTo: note.title).getDocuments();
snapshot.documents.forEach((doc) async {
Expand Down Expand Up @@ -586,6 +586,16 @@ class FirestoreService {
log.e(e.toString());
}
}
updateLinkInFirebase(Link note) async {
log.e(note.id);

try {
await _linksCollectionReference.document(note.id).setData(note.toJson());
log.e(note.toJson());
} on Exception catch (e) {
log.e(e.toString());
}
}
updateUploadLogInFirebase(UploadLog note) async {
log.e(note.id);

Expand Down Expand Up @@ -666,6 +676,9 @@ class FirestoreService {
case Document.Syllabus:
await this.updateSyllabusInFirebase(doc);
break;
case Document.Links:
await this.updateLinkInFirebase(doc);
break;
case Document.UploadLog:
await this.updateUploadLogInFirebase(doc);
break;
Expand Down
Loading

0 comments on commit f472f89

Please sign in to comment.