Add search all keywords in model

This commit is contained in:
Tobias Eidelpes 2021-05-03 10:04:12 +02:00
parent 86f1692660
commit 28749401e3
3 changed files with 8 additions and 3 deletions

View File

@ -16,6 +16,7 @@ class Feed(models.Model):
icon = models.FileField(upload_to='feed-icons', blank=True, null=True,
validators=[FileExtensionValidator(['png', 'svg'])])
keywords = models.TextField(blank=False, null=False)
match_all_keywords = models.BooleanField(blank=True, default=False)
class FeedEntry(models.Model):

View File

@ -14,7 +14,7 @@
<mat-label>Gesuchte Stichwörter</mat-label>
<input matInput formControlName="keywords" placeholder="Spiel,Spaß,Schokolade">
</mat-form-field>
<mat-checkbox>Alle Stichworte müssen enthalten sein</mat-checkbox>
<mat-checkbox formControlName="match_all_keywords">Alle Stichworte müssen enthalten sein</mat-checkbox>
</div>
<div class="input-row text-left">
<mat-form-field class="col">

View File

@ -20,6 +20,7 @@ export class EditierenComponent implements OnInit {
feedForm: FormGroup;
url: String;
active = true;
match_all_keywords = false;
icon: File;
keywords: String;
@ -44,7 +45,8 @@ export class EditierenComponent implements OnInit {
url: this.url,
active: this.active,
icon: [undefined, [FileValidator.maxContentSize(this.maxSize)]],
keywords: this.keywords
keywords: this.keywords,
match_all_keywords: this.match_all_keywords
});
}
@ -60,6 +62,8 @@ export class EditierenComponent implements OnInit {
const form: FormData = new FormData();
form.append('url', feedData.url);
form.append('active', feedData.active);
form.append('match_all_keywords', feedData.match_all_keywords);
console.log('Match all: ' + feedData.match_all_keywords);
if (feedData.keywords != null) {
form.append('keywords', feedData.keywords);
}