Browse Source

add columns to location and reply model

Mohidul Islam 2 years ago
parent
commit
6390131c51

+ 1 - 1
gauth/admin.py

@@ -10,7 +10,7 @@ class UserModelAdmin(admin.ModelAdmin):
 
 
 class LocationsAdmin(admin.ModelAdmin):
 class LocationsAdmin(admin.ModelAdmin):
     list_display = ['location_id', 'care_name', 'location_name', 'website_url',
     list_display = ['location_id', 'care_name', 'location_name', 'website_url',
-                    'review_site_url']
+                    'review_site_url', 'organization']
 
 
 
 
 class LocationManagerAdmin(admin.ModelAdmin):
 class LocationManagerAdmin(admin.ModelAdmin):

+ 2 - 2
gauth/location_utils.py

@@ -23,5 +23,5 @@ def populate_locations():
                 website_url=loc_website,
                 website_url=loc_website,
                 owner=user
                 owner=user
             )
             )
-        if location:
-            print('A new location has been created!')
+            if location:
+                print('A new location has been created!')

+ 18 - 0
gauth/migrations/0016_location_organization.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.0.4 on 2022-07-22 15:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('gauth', '0015_auto_20201230_0940'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='location',
+            name='organization',
+            field=models.CharField(choices=[('ET', 'EnTrust'), ('SC', 'SignatureCare')], default='SC', max_length=2),
+        ),
+    ]

+ 7 - 0
gauth/models.py

@@ -14,6 +14,12 @@ class UserModel(models.Model):
         return self.user.username
         return self.user.username
 
 
 
 
+ORGANIZATION_TYPE = [
+    ('ET', 'EnTrust'),
+    ('SC', 'SignatureCare'),
+]
+
+
 class Location(models.Model):
 class Location(models.Model):
     location_id = models.CharField(max_length=50, primary_key=True)
     location_id = models.CharField(max_length=50, primary_key=True)
     care_name = models.CharField(max_length=50, null=True, blank=True)
     care_name = models.CharField(max_length=50, null=True, blank=True)
@@ -21,6 +27,7 @@ class Location(models.Model):
     website_url = models.URLField()
     website_url = models.URLField()
     review_site_url = models.URLField(null=True, blank=True)
     review_site_url = models.URLField(null=True, blank=True)
     owner = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
     owner = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
+    organization = models.CharField(max_length=2, choices=ORGANIZATION_TYPE, default="SC")
 
 
     def __str__(self):
     def __str__(self):
         return self.care_name if self.care_name else self.location_name
         return self.care_name if self.care_name else self.location_name

+ 2 - 2
review/admin.py

@@ -11,8 +11,8 @@ class ReviewAdmin(admin.ModelAdmin):
 
 
 
 
 class CustomReplyAdmin(admin.ModelAdmin):
 class CustomReplyAdmin(admin.ModelAdmin):
-    list_display = ('reply_category', 'reply_star', 'reply')
-    list_filter = ('reply_category',)
+    list_display = ('reply_category', 'reply_star', 'reply', 'organization')
+    list_filter = ('reply_category', 'organization')
 
 
 
 
 class ReplyAdmin(admin.ModelAdmin):
 class ReplyAdmin(admin.ModelAdmin):

+ 18 - 0
review/migrations/0011_customreply_organization.py

@@ -0,0 +1,18 @@
+# Generated by Django 3.0.4 on 2022-07-22 15:23
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('review', '0010_customreply_reply_star'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='customreply',
+            name='organization',
+            field=models.CharField(choices=[('ET', 'EnTrust'), ('SC', 'SignatureCare')], default='SC', max_length=2),
+        ),
+    ]

+ 6 - 0
review/models.py

@@ -25,10 +25,16 @@ class Review(models.Model):
         return f'{self.reviewer_name} - {self.comment}'
         return f'{self.reviewer_name} - {self.comment}'
 
 
 
 
+ORGANIZATION_TYPE = [
+    ('ET', 'EnTrust'),
+    ('SC', 'SignatureCare'),
+]
+
 class CustomReply(models.Model):
 class CustomReply(models.Model):
     reply = models.TextField()
     reply = models.TextField()
     reply_category = models.CharField(max_length=120)
     reply_category = models.CharField(max_length=120)
     reply_star = models.IntegerField(default=5)
     reply_star = models.IntegerField(default=5)
+    organization = models.CharField(max_length=2, choices=ORGANIZATION_TYPE, default="SC")
 
 
     def __str__(self):
     def __str__(self):
         return f'{self.reply_category} - {self.reply}'
         return f'{self.reply_category} - {self.reply}'