Commit feaaa807 authored by Thodoris Nestoridis's avatar Thodoris Nestoridis

add groups in Boilerplates(ui needs update)

parent e3083e2d
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
......@@ -9,6 +9,8 @@ import { SignupComponent } from './components/singup/singup.component';
import { BoilerplateListComponent } from './components/boilerplate-list/boilerplate-list.component';
import { BoilerplateDetailsComponent } from './components/boilerplate-details/boilerplate-details.component';
import { AddBoilerplateComponent } from './components/add-boilerplate/add-boilerplate.component';
import { GroupboilComponent } from './components/groupboil/groupboil.component';
import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.component';
/*import { PrefixListComponent } from './components/prefix-list/prefix-list.component';
import { PrefixDetailsComponent } from './components/prefix-details/prefix-details.component';
......@@ -18,9 +20,11 @@ const routes: Routes = [
{ path: '', redirectTo: 'login', pathMatch: 'full' },
{ path: 'login', component: LoginComponent },
{ path: 'signup', component: SignupComponent },
{ path: 'boilerplates', component: BoilerplateListComponent, canActivate: [AuthGuard] },
{ path: 'boilerplates/:id', component: BoilerplateDetailsComponent, canActivate: [AuthGuard] },
{ path: 'add-boilerplate', component: AddBoilerplateComponent, canActivate: [AuthGuard] }
{ path: 'groupboilerplates', component: GroupboilComponent, canActivate: [AuthGuard] },
{ path: 'groupboilerplates/:gb/boilerplates', component: BoilerplateListComponent, canActivate: [AuthGuard] },
{ path: 'groupboilerplates/:gb/boilerplates/:id', component: BoilerplateDetailsComponent, canActivate: [AuthGuard] },
{ path: 'groupboilerplates/:gb/boilerplates/add-boilerplate', component: AddBoilerplateComponent, canActivate: [AuthGuard] },
{ path: 'add-groupboil', component: AddGroupboilComponent, canActivate: [AuthGuard] }
/*{ path: '', redirectTo: 'tutorials', pathMatch: 'full' },
{ path: 'prefix', component: PrefixListComponent },
{ path: 'prefix/:id', component: PrefixDetailsComponent },
......
......@@ -30,6 +30,8 @@ import { MainListComponent } from './components/main-list/main-list.component';
import { MainDetailsComponent } from './components/main-details/main-details.component';
import { SuffixListComponent } from './components/suffix-list/suffix-list.component';
import { SuffixDetailsComponent } from './components/suffix-details/suffix-details.component';
import { GroupboilComponent } from './components/groupboil/groupboil.component';
import { AddGroupboilComponent } from './components/add-groupboil/add-groupboil.component';
......@@ -50,6 +52,8 @@ import { SuffixDetailsComponent } from './components/suffix-details/suffix-detai
MainDetailsComponent,
SuffixListComponent,
SuffixDetailsComponent,
GroupboilComponent,
AddGroupboilComponent,
],
imports: [
BrowserModule,
......
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import {ActivatedRoute, Router} from '@angular/router';
import { Boilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-add-boilerplate',
templateUrl: './add-boilerplate.component.html',
......@@ -11,6 +12,7 @@ import { NotifierService } from "angular-notifier";
})
export class AddBoilerplateComponent implements OnInit {
boilerplate: Boilerplate = {
group_of_boilerplate: this.route.snapshot.params.gb,
title: "",
has_prefix: false,
has_main: false,
......@@ -19,7 +21,8 @@ export class AddBoilerplateComponent implements OnInit {
submitted = false;
private readonly notifier: NotifierService;
constructor(private boilerplatelService: BoilerplateService, private router:Router, notifierService: NotifierService) {
constructor(private boilerplatelService: BoilerplateService, private route: ActivatedRoute,
private router: Router, notifierService: NotifierService) {
this.notifier = notifierService;
}
......@@ -28,18 +31,19 @@ export class AddBoilerplateComponent implements OnInit {
saveBoilerplate(): void {
const data = {
group_of_boilerplate: this.route.snapshot.params.gb,
title: this.boilerplate.title,
has_prefix: this.boilerplate.has_prefix,
has_main: this.boilerplate.has_main,
has_suffix: this.boilerplate.has_suffix
};
this.boilerplatelService.create(data)
this.boilerplatelService.create(this.route.snapshot.params.gb, data)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.submitted = true;
this.router.navigate(['/boilerplates']);
this.router.navigate(['/groupboilerplates/'+this.route.snapshot.params.gb+'/boilerplates']);
},
error => {
console.log(error);
......@@ -51,6 +55,7 @@ export class AddBoilerplateComponent implements OnInit {
newBoilerplate(): void {
this.submitted = false;
this.boilerplate = {
group_of_boilerplate: this.route.snapshot.params.gb,
title: "",
has_prefix: false,
has_main: false,
......
<div>
<div class="submit-form">
<div class="form-group">
<label for="title">Requirement Title</label>
<input
type="text"
class="form-control"
id="title_bgroup"
required
[(ngModel)]="groupboilerplate.title_bgroup"
name="title_bgroup"
/>
<button (click)="saveBoilerplate()" class="btn btn-success" >Submit</button>
</div>
</div>
\ No newline at end of file
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AddGroupboilComponent } from './add-groupboil.component';
describe('AddGroupboilComponent', () => {
let component: AddGroupboilComponent;
let fixture: ComponentFixture<AddGroupboilComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ AddGroupboilComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(AddGroupboilComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import {Router} from '@angular/router';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { NotifierService } from "angular-notifier";
@Component({
selector: 'app-add-groupboil',
templateUrl: './add-groupboil.component.html',
styleUrls: ['./add-groupboil.component.scss']
})
export class AddGroupboilComponent implements OnInit {
groupboilerplate: GroupBoilerplate = {
title_bgroup: "",
};
submitted = false;
private readonly notifier: NotifierService;
constructor(private boilerplatelService: BoilerplateService, private router:Router, notifierService: NotifierService) {
this.notifier = notifierService;
}
ngOnInit(): void {
}
saveBoilerplate(): void {
const data = {
title_bgroup: this.groupboilerplate.title_bgroup,
};
this.boilerplatelService.creategroupboil(data)
.subscribe(
response => {
this.notifier.notify("success",(JSON.stringify(response)));
this.submitted = true;
this.router.navigate(['/groupboilerplates']);
},
error => {
console.log(error);
//error, warning, success, info, default
this.notifier.notify("warning",(JSON.stringify(error["error"]["title"][0])));
});
}
newBoilerplate(): void {
this.submitted = false;
this.groupboilerplate = {
title_bgroup: "",
};
}
}
......@@ -27,11 +27,11 @@ export class BoilerplateDetailsComponent implements OnInit {
ngOnInit(): void {
this.message = '';
this.getBoilerplate(this.route.snapshot.params.id);
this.getBoilerplate(this.route.snapshot.params.gb, this.route.snapshot.params.id);
}
getBoilerplate(id: string): void {
this.boilerplateService.get(id)
getBoilerplate(gb:any, id: number): void {
this.boilerplateService.get(gb, id)
.subscribe(
data => {
this.currentboilerplate = data;
......@@ -43,7 +43,7 @@ export class BoilerplateDetailsComponent implements OnInit {
}
updateBoilerplate(): void {
this.boilerplateService.update(this.currentboilerplate.id, this.currentboilerplate)
this.boilerplateService.update(this.route.snapshot.params.gb, this.currentboilerplate.id, this.currentboilerplate)
.subscribe(
response => {
console.log(response);
......@@ -57,7 +57,7 @@ export class BoilerplateDetailsComponent implements OnInit {
deleteBoilerplate(): void {
if(confirm("Αre you sure you want to delete this Boilerplate?")) {
this.boilerplateService.delete(this.currentboilerplate.id)
this.boilerplateService.delete(this.route.snapshot.params.gb, this.currentboilerplate.id)
.subscribe(
response => {
console.log(response);
......
<div>
<div>
<input type="button" value="Add Boilepate" (click)="GetRoute()"/>
</div>
</div>
<div class="list row">
<div class="col-md-8">
<div class="input-group mb-3">
......@@ -19,7 +25,7 @@
</div>
</div>
</div>
</div>
</div>
<table mat-table [dataSource]="newdataSource" class="mat-elevation-z8">
......@@ -54,7 +60,7 @@
<ng-container matColumnDef="action">
<th mat-header-cell *matHeaderCellDef> Action </th>
<td mat-cell *matCellDef="let element" class="action-link">
<a class="badge badge-warning" routerLink="/boilerplates/{{ element.id }}">Edit</a>
<a class="badge badge-warning" routerLink="{{element.id}}">Edit</a>
</td>
</ng-container>
......
......@@ -3,6 +3,7 @@ import { Boilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateData } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
import { PrefixService } from 'src/app/services/prefix.service';
import { ActivatedRoute, Router } from '@angular/router';
......@@ -30,7 +31,8 @@ export class BoilerplateListComponent implements OnInit {
main: any;
suffix: any;
constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService) { }
constructor(private boilerplateService: BoilerplateService, private prefixService: PrefixService, private route: ActivatedRoute,
private router: Router) { }
ngOnInit(): void {
this.retrieveBoilerplates();
......@@ -38,7 +40,7 @@ export class BoilerplateListComponent implements OnInit {
}
retrieveBoilerplates(): void {
this.boilerplateService.getAll()
this.boilerplateService.getAll(this.route.snapshot.params.gb)
.subscribe(
data => {
this.boilerplates = data;
......@@ -52,7 +54,7 @@ export class BoilerplateListComponent implements OnInit {
retrieve(): void {
this.boilerplateService.getAllData()
this.boilerplateService.getAllData(this.route.snapshot.params.gb)
.subscribe(
data => {
this.boilerplatesdata =data;
......@@ -79,7 +81,7 @@ export class BoilerplateListComponent implements OnInit {
SearchTitle(): void {
if (this.title != ''){
this.boilerplateService.findByTitle(this.title)
this.boilerplateService.findByTitle(this.route.snapshot.params.gb, this.title)
.subscribe(
data => {
this.boilerplates = data;
......@@ -95,5 +97,11 @@ export class BoilerplateListComponent implements OnInit {
this.retrieveBoilerplates();
}
}
GetRoute(): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates/add-boilerplate'])
}
GetRoutedit(id: any): void {
this.router.navigate(['/groupboilerplates/'+ this.route.snapshot.params.gb +'/boilerplates'+ id])
}
}
<p>groupboil works!</p>
<div>
<a routerLink="/add-groupboil">Add Boilepate</a>
</div>
<li *ngFor="let gb of grouboilerplates">
<a class="badge badge-warning" routerLink="/groupboilerplates/{{gb.id}}/boilerplates">"{{gb.title_bgroup}}"</a>
<span class="badge">{{gb.id}}</span>
</li>
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { GroupboilComponent } from './groupboil.component';
describe('GroupboilComponent', () => {
let component: GroupboilComponent;
let fixture: ComponentFixture<GroupboilComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ GroupboilComponent ]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(GroupboilComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
import { Component, OnInit } from '@angular/core';
import { GroupBoilerplate } from 'src/app/models/boilerplate.model';
import { BoilerplateService } from 'src/app/services/boilerplate.service';
@Component({
selector: 'app-groupboil',
templateUrl: './groupboil.component.html',
styleUrls: ['./groupboil.component.scss']
})
export class GroupboilComponent implements OnInit {
grouboilerplates?: GroupBoilerplate[];
constructor(private boilerplateService: BoilerplateService) { }
ngOnInit(): void {
this.retrievegroupBoilerplates();
}
retrievegroupBoilerplates(): void {
this.boilerplateService.getAllgroupboil()
.subscribe(
data => {console.log(data);
this.grouboilerplates = data;
},
error => {
console.log(error);
});
}
}
......@@ -35,7 +35,7 @@ export class LoginComponent implements OnInit {
login(email: string, password: string) {
this.authService.login(email, password).subscribe(
success => this.router.navigate(['boilerplates']),
success => this.router.navigate(['groupboilerplates']),
error => this.notifier.notify("warning",(JSON.stringify("You have entered an invalid username or password")))
);
}
......
export class Boilerplate {
id?:any;
group_of_boilerplate?: any;
title?: string;
has_prefix?: boolean;
has_main?: boolean;
......@@ -12,4 +13,9 @@ export class BoilerplateData {
prefix_data?: string;
main_data?: string;
suffix_data?: string;
}
export class GroupBoilerplate {
id?:any;
title_bgroup?: string;
}
\ No newline at end of file
......@@ -9,9 +9,6 @@
</div>
<div fxFlex fxLayout fxHide.xs fxLayoutAlign="end">
<ul fxLayout fxLayoutGap="15px" class="navigation-items">
<div>
<a routerLink="/add-boilerplate">Add Boilepate</a>
</div>
<div>
<a mat-menu-item (click)="LogOut()">Log out</a>
</div>
......
......@@ -3,8 +3,10 @@ import { HttpClient } from '@angular/common/http';
import { HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Boilerplate } from '../models/boilerplate.model';
import { GroupBoilerplate } from '../models/boilerplate.model';
const baseUrl = 'http://155.207.131.19:8000/api-auth/boilerplates/';
const baseUrl = '/boilerplates/';
const baseUrlgb = 'http://155.207.131.19:8000/api-auth/groupboilerplates/';
@Injectable({
providedIn: 'root'
......@@ -13,32 +15,42 @@ export class BoilerplateService {
constructor(private http: HttpClient) { }
getAll(): Observable<Boilerplate[]> {
return this.http.get<Boilerplate[]>(baseUrl);
creategroupboil(data: any): Observable<any> {
return this.http.post(baseUrlgb, data);
}
getAllData(): Observable<Boilerplate[]> {
return this.http.get<Boilerplate[]>(baseUrl + `boilerplatedata/`);
getAllgroupboil(): Observable<Boilerplate[]> {
return this.http.get<[GroupBoilerplate]>(baseUrlgb);
}
get(id: any): Observable<Boilerplate> {
return this.http.get(`${baseUrl}${id}`);
getAll(gb: any): Observable<Boilerplate[]> {
//console.log(baseUrlgb + gb + baseUrl)
return this.http.get<Boilerplate[]>(baseUrlgb + gb + baseUrl);
}
create(data: any): Observable<any> {
return this.http.post(baseUrl, data);
getAllData(gb: any): Observable<Boilerplate[]> {
return this.http.get<Boilerplate[]>(baseUrlgb + gb + baseUrl+ `boilerplatedata/`);
}
update(id: any, data: any): Observable<any> {
return this.http.put(`${baseUrl}${id}/`, data);
get(gb: any, id: any): Observable<Boilerplate> {
console.log(id)
return this.http.get(`${baseUrlgb}${gb}${baseUrl}${id}`);
}
delete(id: any): Observable<any> {
return this.http.delete(`${baseUrl}${id}`);
create(gb: any, data: any): Observable<any> {
return this.http.post(baseUrlgb + gb + baseUrl, data);
}
findByTitle(title: any): Observable<Boilerplate[]> {
return this.http.get<Boilerplate[]>(`${baseUrl}title=${title}`);
update(gb: any,id: any, data: any): Observable<any> {
return this.http.put(`${baseUrlgb}${gb}${baseUrl}${id}/`, data);
}
delete(gb: any, id: any): Observable<any> {
return this.http.delete(`${baseUrlgb}${gb}${baseUrl}${id}`);
}
findByTitle(gb: any, title: any): Observable<Boilerplate[]> {
return this.http.get<Boilerplate[]>(`${baseUrlgb}${gb}${baseUrl}title=${title}`);
}
}
......@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Main } from '../models/main.model';
const baseUrl = 'http://155.207.131.19:8000/api-auth/boilerplates/';
const baseUrl = 'http://155.207.131.19:8000/api-auth/groupboilerplates/0/boilerplates/';
const Url = '/main/';
@Injectable({
......
......@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Prefix } from '../models/prefix.model';
const baseUrl = 'http://155.207.131.19:8000/api-auth/boilerplates/';
const baseUrl = 'http://155.207.131.19:8000/api-auth/groupboilerplates/0/boilerplates/';
const Url = '/prefix/';
@Injectable({
......
......@@ -3,7 +3,7 @@ import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Suffix } from '../models/suffix.model';
const baseUrl = 'http://155.207.131.19:8000/api-auth/boilerplates/';
const baseUrl = 'http://155.207.131.19:8000/api-auth/groupboilerplates/0/boilerplates/';
const Url = '/suffix/';
@Injectable({
......
......@@ -55,17 +55,32 @@ def create_prefix(instance):
prefix = Prefix(prefix_boilerplate = instance.boilerplate, prefixgroup = instance)
prefix.save()
def create_data(instance):
data = BoilerplateData(boilerplate_data_id = instance, owner_data = instance.owner, title_data= instance.title)
data = BoilerplateData(boilerplate_data_id = instance, owner_data = instance.owner, title_data= instance.title, group_of_boilerplate_data = instance.group_of_boilerplate )
data.save()
def create_extra_prefix(instance, now_prefix):
prefix = Prefix(prefixgroup = instance.prefixgroup, prefix_boilerplate = instance.prefix_boilerplate)
prefix.save()
def create_infer_result(instance):
pass
class BoilerplateGroup(models.Model):
boilerplate_owner = models.ForeignKey(User, related_name='boilerplate_group_owner', on_delete=models.CASCADE)
title_bgroup = models.CharField(max_length=30, unique=True)
def save(self, **kwargs):
super(BoilerplateGroup, self).save(**kwargs)
class Boilerplate(models.Model):
owner = models.ForeignKey(User, related_name='boilerplate', on_delete=models.CASCADE)
owner = models.ForeignKey(User, related_name='boilerplate', on_delete=models.CASCADE)
group_of_boilerplate = models.ForeignKey(BoilerplateGroup, related_name='owner_of_boilerplate', on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
title = models.CharField(max_length=30, unique=True)
has_prefix = models.BooleanField(default=False)
......@@ -162,7 +177,8 @@ class Prefix(models.Model):
class BoilerplateData(models.Model):
owner_data = models.ForeignKey(User, related_name='boilerplate_data', on_delete=models.CASCADE)
owner_data = models.ForeignKey(User, related_name='boilerplate_data', on_delete=models.CASCADE)
group_of_boilerplate_data = models.ForeignKey(BoilerplateGroup, related_name='group_of_boilerplate_data', on_delete=models.CASCADE)
boilerplate_data_id = models.ForeignKey(Boilerplate, related_name='boilerplate_data_id', on_delete=models.CASCADE)
title_data = models.CharField(default="", max_length=30, unique=True)
prefix_data = models.CharField(default="", max_length=100, blank=True)
......@@ -170,4 +186,12 @@ class BoilerplateData(models.Model):
suffix_data = models.CharField(max_length=100, blank=True)
class Meta:
ordering = ['boilerplate_data_id']
\ No newline at end of file
ordering = ['boilerplate_data_id']
#class InferenceResults(models.Model):
# owner_infer = models.ForeignKey(User, related_name='owner_infer', on_delete=models.CASCADE)
# inference_data = models.CharField(default="")
# class Meta:
# ordering = ['owner_infer']
from rest_framework import serializers
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, BoilerplateData
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, BoilerplateData, BoilerplateGroup
class BoilerplateSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.username')
class Meta:
model = Boilerplate
fields = ('id', 'owner', 'title', 'has_prefix', 'has_main', 'has_suffix')
fields = ('id', 'group_of_boilerplate', 'owner', 'title', 'has_prefix', 'has_main', 'has_suffix')
class PrefixSerializer(serializers.ModelSerializer):
......@@ -23,3 +23,10 @@ class BoilerplateDataSerializer(serializers.ModelSerializer):
class Meta:
model = BoilerplateData
fields = '__all__'
class BoilerplateGroupSerializer(serializers.ModelSerializer):
boilerplate_owner = serializers.ReadOnlyField(source='owner.username')
class Meta:
model = BoilerplateGroup
fields = ('id', 'boilerplate_owner', 'title_bgroup')
......@@ -7,21 +7,24 @@ from .views import user_views, requirements_views, main_req_views, suffix_req_vi
urlpatterns = [
path('users/', user_views.UserList.as_view(), name='api-user-list'),
path('users/<uuid:pk>/', user_views.UserDetail.as_view(), name='api-post-details'),
path('boilerplates/', requirements_views.BoilerplateListCreateAPIView.as_view(), name='api-requirements-list'),
path('boilerplates/<int:pk>/', requirements_views.BoilerplateDetailsAPIView.as_view(), name='api-requirements-details'),
path('boilerplates/boilerplatedata/', requirements_views.BoilerplateDataListAPIView.as_view(), name='api-boilerlplate-list-data'),
re_path('boilerplates/(?:title=(?P<title_1>\w+)/)?$', requirements_views.BoilerplateList.as_view(), name='api-requirements-details-per-title'),
path('groupboilerplates/', requirements_views.BoilerplateGroupCreateAPIView.as_view(), name='api-groupboilerplates-create'),
path('groupboilerplates/<int:pk>/', requirements_views.BoilerplateGroupList.as_view(), name='api-groupboilerplates-list'),
path('groupboilerplates/<int:groupboil>/boilerplates/', requirements_views.BoilerplateListCreateAPIView.as_view(), name='api-requirements-list'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:pk>/', requirements_views.BoilerplateDetailsAPIView.as_view(), name='api-requirements-details'),
path('groupboilerplates/<int:groupboil>/boilerplates/boilerplatedata/', requirements_views.BoilerplateDataListAPIView.as_view(), name='api-boilerlplate-list-data'),
re_path('groupboilerplates/<int:groupboil>/boilerplates/(?:title=(?P<title_1>\w+)/)?$', requirements_views.BoilerplateList.as_view(), name='api-requirements-details-per-title'),
#'''Prefix'''
path('boilerplates/<int:boilerplate>/prefix/', requirements_views.PrefixListAPIView.as_view(), name='api-prefix-list'),
path('boilerplates/<int:boilerplate>/prefix/<int:pk>/', requirements_views.PrefixDetailsAPIView.as_view(), name='api-prefix-details'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/prefix/', requirements_views.PrefixListAPIView.as_view(), name='api-prefix-list'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/prefix/<int:pk>/', requirements_views.PrefixDetailsAPIView.as_view(), name='api-prefix-details'),
#'''MAIN'''
path('boilerplates/<int:boilerplate>/main/', main_req_views.MainListAPIView.as_view(), name='api-main-list'),
path('boilerplates/<int:boilerplate>/main/<int:pk>/', main_req_views.MainDetailsAPIView.as_view(), name='api-main-details'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/main/', main_req_views.MainListAPIView.as_view(), name='api-main-list'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/main/<int:pk>/', main_req_views.MainDetailsAPIView.as_view(), name='api-main-details'),
#'''SUFFIX'''
path('boilerplates/<int:boilerplate>/suffix/', suffix_req_views.SuffixListAPIView.as_view(), name='api-suffix-list'),
path('boilerplates/<int:boilerplate>/suffix/<int:pk>/', suffix_req_views.SuffixDetailsAPIView.as_view(), name='api-suffix-details'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/suffix/', suffix_req_views.SuffixListAPIView.as_view(), name='api-suffix-list'),
path('groupboilerplates/<int:groupboil>/boilerplates/<int:boilerplate>/suffix/<int:pk>/', suffix_req_views.SuffixDetailsAPIView.as_view(), name='api-suffix-details'),
#PREFIX CHOICES DATA
path('prefix/choices/simpleprefix/', requirements_views.PrefixChoicesViewSet.as_view(), name='simpleprefixchoices'),
......
......@@ -5,10 +5,10 @@ from django.http import HttpResponse, JsonResponse
from django.views.decorators.csrf import csrf_exempt
from rest_framework.parsers import JSONParser
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, PREFIX_CHOICES, LOGIC_CONNECTIVE, VERB_CHOICES
from reqman.apps.reqtool.models.requirements import Prefix, Boilerplate, BoilerplateGroup, PREFIX_CHOICES, LOGIC_CONNECTIVE, VERB_CHOICES
from reqman.apps.reqtool.models.requirements import VERB_CHOICES, ITEM_CHOICES, SYSTEM_CHOICES, FUNCTION_CHOICES, STATE_CHOICES
from reqman.apps.reqtool.models.requirements import ITEM_CHOICES, FLOW_CHOICES, FUNCTION_CHOICES, STATE_VALUE_CHOICES
from reqman.apps.reqtool.rest_api.serializers.requirements import BoilerplateSerializer, PrefixSerializer, BoilerplateDataSerializer
from reqman.apps.reqtool.rest_api.serializers.requirements import BoilerplateSerializer, PrefixSerializer, BoilerplateDataSerializer, BoilerplateGroupSerializer
from reqman.apps.permissions import IsOwnerOrReadOnly
from reqman.apps.reqtool.rest_api.services import fuseki
from rest_framework.response import Response
......@@ -17,6 +17,36 @@ from rest_framework.views import APIView
from reqman.apps.reqtool.models.requirements import BoilerplateData
from django.shortcuts import get_object_or_404
##
class BoilerplateGroupCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupSerializer
def get_queryset(self):
queryset_boil = BoilerplateGroup.objects.filter(boilerplate_owner = self.request.user)
return queryset_boil
#Custom actions when POST
def perform_create(self, serializer):
serializer.save(boilerplate_owner=self.request.user)
class BoilerplateGroupList(ListAPIView):
"""
API view to retrieve list of posts based on title of Boilerplate
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateGroupSerializer
queryset = Boilerplate.objects.all()
###
class BoilerplateListCreateAPIView(ListCreateAPIView):
"""
API view to retrieve list of posts or create new
......@@ -27,7 +57,8 @@ class BoilerplateListCreateAPIView(ListCreateAPIView):
def get_queryset(self):
#print(title)
queryset_boil = Boilerplate.objects.filter(owner = self.request.user)
group_gb = self.kwargs['groupboil']
queryset_boil = Boilerplate.objects.filter(owner = self.request.user, group_of_boilerplate = group_gb)
return queryset_boil
#Custom actions when POST
......@@ -43,13 +74,14 @@ class BoilerplateList(ListAPIView):
"""
permission_classes = [permissions.IsAuthenticatedOrReadOnly]
serializer_class = BoilerplateSerializer
queryset = Boilerplate.objects.all()
#queryset = Boilerplate.objects.all()
def get_queryset(self):
group_gb = self.kwargs['groupboil']
title = self.kwargs['title_1']
#print(title)
queryset_title = Boilerplate.objects.filter(title = title)
queryset_title = Boilerplate.objects.filter(title = title, group_of_boilerplate = group_gb)
return queryset_title
......@@ -133,6 +165,7 @@ class PrefixDetailsAPIView(RetrieveUpdateDestroyAPIView):
instance.delete()
class BoilerplateDataListAPIView(ListAPIView):
"""
API view to retrieve list of posts or create new
......@@ -142,8 +175,8 @@ class BoilerplateDataListAPIView(ListAPIView):
#queryset = Prefix.objects.all()
def get_queryset(self):
#print(title)
queryset_boil_data = BoilerplateData.objects.filter(owner_data = self.request.user)
group_gb = self.kwargs['groupboil']
queryset_boil_data = BoilerplateData.objects.filter(owner_data = self.request.user, group_of_boilerplate_data = group_gb)
return queryset_boil_data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment