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, icon = models.FileField(upload_to='feed-icons', blank=True, null=True,
validators=[FileExtensionValidator(['png', 'svg'])]) validators=[FileExtensionValidator(['png', 'svg'])])
keywords = models.TextField(blank=False, null=False) keywords = models.TextField(blank=False, null=False)
match_all_keywords = models.BooleanField(blank=True, default=False)
class FeedEntry(models.Model): class FeedEntry(models.Model):
@ -24,7 +25,7 @@ class FeedEntry(models.Model):
class Tweet(models.Model): class Tweet(models.Model):
icon = models.ForeignKey(Icon, on_delete=models.CASCADE,null=True) icon = models.ForeignKey(Icon, on_delete=models.CASCADE, null=True)
text = models.CharField(max_length=137) text = models.CharField(max_length=137)
date_time = models.DateTimeField() date_time = models.DateTimeField()
url = models.CharField(max_length=100) url = models.CharField(max_length=100)

View File

@ -14,7 +14,7 @@
<mat-label>Gesuchte Stichwörter</mat-label> <mat-label>Gesuchte Stichwörter</mat-label>
<input matInput formControlName="keywords" placeholder="Spiel,Spaß,Schokolade"> <input matInput formControlName="keywords" placeholder="Spiel,Spaß,Schokolade">
</mat-form-field> </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>
<div class="input-row text-left"> <div class="input-row text-left">
<mat-form-field class="col"> <mat-form-field class="col">

View File

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