diff --git a/Praktikum2/ppm2/app/__pycache__/category.cpython-35.pyc b/Praktikum2/ppm2/app/__pycache__/category.cpython-35.pyc index 478bda0..adc49b3 100644 Binary files a/Praktikum2/ppm2/app/__pycache__/category.cpython-35.pyc and b/Praktikum2/ppm2/app/__pycache__/category.cpython-35.pyc differ diff --git a/Praktikum2/ppm2/app/__pycache__/database.cpython-35.pyc b/Praktikum2/ppm2/app/__pycache__/database.cpython-35.pyc index a86d93c..047d0ec 100644 Binary files a/Praktikum2/ppm2/app/__pycache__/database.cpython-35.pyc and b/Praktikum2/ppm2/app/__pycache__/database.cpython-35.pyc differ diff --git a/Praktikum2/ppm2/app/__pycache__/eval.cpython-35.pyc b/Praktikum2/ppm2/app/__pycache__/eval.cpython-35.pyc index 04930ee..5cc8dc9 100644 Binary files a/Praktikum2/ppm2/app/__pycache__/eval.cpython-35.pyc and b/Praktikum2/ppm2/app/__pycache__/eval.cpython-35.pyc differ diff --git a/Praktikum2/ppm2/app/category.py b/Praktikum2/ppm2/app/category.py index 649364c..5987861 100644 --- a/Praktikum2/ppm2/app/category.py +++ b/Praktikum2/ppm2/app/category.py @@ -16,18 +16,44 @@ class Category(object): self.db = database.Database() #------------------------------------------------------- - def GET(self, cat=None): + def GET(self, cat, view, id=None): #------------------------------------------------------- data = {} - if(cat != None): + if(cat != "Index"): self.db.ReadAll() - data['content'] = {} - data['headings'] = {} - data['category'] = cat - data['content'] = self.db.data[cat] - if(len(data['content']) != 0): - print(len(data['content'])) - contentFirst = list(data['content'].keys())[0] - data['headings'] = list(data['content'][contentFirst].keys()) + if(view == "List"): + data['content'] = {} + data['headings'] = {} + data['category'] = cat + data['content'] = self.db.data[cat] + if(len(data['content']) != 0): + print(len(data['content'])) + contentFirst = list(data['content'].keys())[0] + data['headings'] = list(data['content'][contentFirst].keys()) + elif(view == "Detail"): + data['category'] = cat + if(id != None): + data['id'] = id + data['content'] = self.db.ReadEntry(cat, id) + else: + data['id'] = None + data['content'] = self.db.GetDefault(cat) + if(cat == 'Angebote'): + data['Firmen'] = self.db.data['Firmen'] print(data) return json.dumps(data) + + #------------------------------------------------------- + def POST(self, cat, **data): + #------------------------------------------------------- + self.db.Save(data, cat) + print(data) + return self.GET(cat, "List") + + + #------------------------------------------------------- + def DELETE(self, cat, id): + #------------------------------------------------------- + print("Delete",cat,id) + self.db.Delete(cat, id) + return self.GET(cat, "List") diff --git a/Praktikum2/ppm2/app/database.py b/Praktikum2/ppm2/app/database.py index 36c072a..14d2465 100644 --- a/Praktikum2/ppm2/app/database.py +++ b/Praktikum2/ppm2/app/database.py @@ -71,7 +71,7 @@ class Database(object): status_b = False id = data['id'] print("ID: ", id, "\n") - if(id != "None"): + if(id != ""): if id in self.data[category]: file = codecs.open(os.path.join('data', category, id+'.json'), 'w', 'utf-8') file.write(json.dumps(data, indent=3, ensure_ascii=True)) diff --git a/Praktikum2/ppm2/data/Angebote/23.json b/Praktikum2/ppm2/data/Angebote/23.json deleted file mode 100644 index b28de59..0000000 --- a/Praktikum2/ppm2/data/Angebote/23.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "Name": "Angebot IBM 1", - "ZeitraumBis": "01.01.2018", - "id": "23", - "Firmenbetreuer": "Sepp Meine", - "Firma": "IBM", - "Voraussetzungen": "Keine", - "Lehrender": "7", - "Status": "aktuell", - "Beschreibung": "Praxisphasenplatz bei IBM", - "ZeitraumVon": "01.01.2017", - "Student": "9" -} \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Angebote/26.json b/Praktikum2/ppm2/data/Angebote/26.json deleted file mode 100644 index f2fd625..0000000 --- a/Praktikum2/ppm2/data/Angebote/26.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "id": "26", - "ZeitraumVon": "02.02.2019", - "Firma": "Apple", - "Student": "10", - "Beschreibung": "Beschreibung", - "Name": "Name", - "Lehrender": "5", - "Firmenbetreuer": "Firmenbetreuer3", - "Voraussetzungen": "Kein", - "Status": "aktuell", - "ZeitraumBis": "02.02.2020" -} \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Firmen/last.json b/Praktikum2/ppm2/data/Firmen/last.json index 62f9457..c793025 100644 --- a/Praktikum2/ppm2/data/Firmen/last.json +++ b/Praktikum2/ppm2/data/Firmen/last.json @@ -1 +1 @@ -6 \ No newline at end of file +7 \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Lehrender/7.json b/Praktikum2/ppm2/data/Lehrender/7.json deleted file mode 100644 index 2f4b91f..0000000 --- a/Praktikum2/ppm2/data/Lehrender/7.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "Titel": "Prof", - "id": "7", - "Lehrgebiet": "Informatik", - "Name": "Adalbert", - "Vorname": "Bastian" -} \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Studenten/10.json b/Praktikum2/ppm2/data/Studenten/10.json deleted file mode 100644 index 31ac8db..0000000 --- a/Praktikum2/ppm2/data/Studenten/10.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Vorname": "Timo", - "Name": "Ben", - "Matrikelnummer": "3", - "id": "10" -} \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Studenten/13.json b/Praktikum2/ppm2/data/Studenten/13.json index e463503..9355135 100644 --- a/Praktikum2/ppm2/data/Studenten/13.json +++ b/Praktikum2/ppm2/data/Studenten/13.json @@ -1,6 +1,6 @@ { "id": "13", - "Name": "Edmund", "Vorname": "Adalbert", - "Matrikelnummer": "1" + "Matrikelnummer": "1", + "Name": "Edmund" } \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Studenten/9.json b/Praktikum2/ppm2/data/Studenten/9.json deleted file mode 100644 index a4bd70d..0000000 --- a/Praktikum2/ppm2/data/Studenten/9.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Vorname": "Gregor", - "Name": "Klemens", - "Matrikelnummer": "2", - "id": "9" -} \ No newline at end of file diff --git a/Praktikum2/ppm2/data/Studenten/last.json b/Praktikum2/ppm2/data/Studenten/last.json index da2d398..3f10ffe 100644 --- a/Praktikum2/ppm2/data/Studenten/last.json +++ b/Praktikum2/ppm2/data/Studenten/last.json @@ -1 +1 @@ -14 \ No newline at end of file +15 \ No newline at end of file diff --git a/Praktikum2/ppm2/static/js/ppm.js b/Praktikum2/ppm2/static/js/ppm.js index 4761938..0049a30 100644 --- a/Praktikum2/ppm2/static/js/ppm.js +++ b/Praktikum2/ppm2/static/js/ppm.js @@ -42,27 +42,27 @@ class PPM { case 'index': - this.LoadContent('/category/', 'index.tpl'); + this.LoadContent('/category/?cat=Index&view=List', 'index.tpl'); break; case 'categoryStudenten': - this.LoadContent('/category/?cat=Studenten', 'list.tpl'); + this.LoadContent('/category/?cat=Studenten&view=List', 'list.tpl'); break case 'categoryLehrender': - this.LoadContent('/category/?cat=Lehrender', 'list.tpl'); + this.LoadContent('/category/?cat=Lehrender&view=List', 'list.tpl'); break case 'categoryFirmen': - this.LoadContent('/category/?cat=Firmen', 'list.tpl'); + this.LoadContent('/category/?cat=Firmen&view=List', 'list.tpl'); break case 'choice': - this.LoadContent('/choice', 'listChoice.tpl'); + this.LoadContent('/choice/?view=List', 'listChoice.tpl'); break case 'evalStudenten': @@ -83,45 +83,81 @@ class PPM case 'NewStudenten': console.log("NewStudenten"); + this.LoadContent('/category/?cat=Studenten&view=Detail', 'detail.tpl'); break case 'NewLehrender': console.log("NewLehrender"); + this.LoadContent('/category/?cat=Lehrenden&view=Detail', 'detail.tpl'); break case 'NewFirmen': console.log("NewFirmen"); + this.LoadContent('/category/?cat=Firmen&view=Detail', 'detail.tpl'); break case 'ModifyStudenten': console.log("ModifyStudenten: ", selectedId); + this.LoadContent('/category/?cat=Studenten&view=Detail&id='+ selectedId, 'detail.tpl'); break - case 'ModifyLehrenden': + case 'ModifyLehrender': - console.log("ModifyLehrenden", selectedId); + console.log("ModifyLehrender", selectedId); + this.LoadContent('/category/?cat=Lehrender&view=Detail&id='+ selectedId, 'detail.tpl'); break case 'ModifyFirmen': console.log("ModifyFirmen", selectedId); + this.LoadContent('/category/?cat=Firmen&view=Detail&id='+ selectedId, 'detail.tpl'); break case 'DeleteStudenten': console.log("DeleteStudenten", selectedId); + if (confirm("Soll der Eintrag wirklich geloescht werden?")) { + console.log("DELETE"); + this.DeleteContent('/category/?cat=Studenten&id='+selectedId, 'categoryStudenten'); + } break - case 'DeleteLehrenden': + case 'DeleteLehrender': - console.log("DeleteLehrenden", selectedId); + console.log("DeleteLehrender", selectedId); + if (confirm("Soll der Eintrag wirklich geloescht werden?")) { + console.log("DELETE"); + this.DeleteContent('/category/?cat=Lehrender&id='+selectedId, 'categoryLehrender'); + } break case 'DeleteFirmen': console.log("DeleteFirmen", selectedId); + if (confirm("Soll der Eintrag wirklich geloescht werden?")) { + console.log("DELETE"); + this.DeleteContent('/category/?cat=Firmen&id='+selectedId, 'categoryFirmen'); + } + break + + case 'SaveCategoryStudenten': + + var data = $("#idForm").serialize(); + this.SaveContent('/category/?cat=Studenten&'+data, 'categoryStudenten'); + break + + case 'SaveCategoryLehrende': + + var data = $("#idForm").serialize(); + this.SaveContent('/category/?cat=Lehrender&'+data, 'categoryLehrender'); + break + + case 'SaveCategoryFirmen': + + var data = $("#idForm").serialize(); + this.SaveContent('/category/?cat=Firmen&'+data, 'categoryFirmen'); break default: @@ -139,10 +175,10 @@ class PPM context: this }) .done(function (json) { - //console.log("JSON: ", json); + console.log("JSON: ", json); var result = this.TemplateManager_o.execute_px( template, json ); - //console.log("RESULT: ", result); + console.log("RESULT: ", result); //$( ".clContent" ).replaceWith(result); $( ".clContent" ).empty(); @@ -150,10 +186,42 @@ class PPM this.BodyTableSelect(); console.log("TM DONE"); }) - .fail(function(jqXHR_opl, textStatus_spl) { - alert( "[PPM] Fehler bei Anforderung: " + textStatus_spl ); + .fail(function(jqXHR_opl, textStatus) { + alert( "[PPM] Fehler bei Anforderung: " + textStatus ); }); } + + SaveContent( path, menu ) + { + $.ajax({ + dataType: "json", + url: path, + type: 'POST', + context: this + }) + .done(function (json) { + this.Menu(menu); + }) + .fail(function(jqXHR_opl, textStatus) { + alert( "[PPM] Fehler bei Anforderung: " + textStatus ); + }); + } + + DeleteContent( path, menu ) + { + $.ajax({ + dataType: "json", + url: path, + type: 'DELETE', + context: this + }) + .done(function (json) { + this.Menu(menu); + }) + .fail(function(jqXHR_opl, textStatus) { + alert( "[PPM] Fehler bei Anforderung: " + textStatus ); + }); + } } diff --git a/Praktikum2/ppm2/templates/detail.tpl b/Praktikum2/ppm2/templates/detail.tpl new file mode 100644 index 0000000..e1cc601 --- /dev/null +++ b/Praktikum2/ppm2/templates/detail.tpl @@ -0,0 +1,58 @@ +