Skip to content

Commit

Permalink
Remove admin_comment from company
Browse files Browse the repository at this point in the history
  • Loading branch information
juniwbjerde committed Sep 25, 2024
1 parent 19a385b commit cfa6fed
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
1 change: 0 additions & 1 deletion lego/apps/companies/fixtures/development_companies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
payment_mail: [email protected]
address: Postboks 134 Sentrum, 0102 Oslo
company_type: 'Konsulent, Data&Komtek'
admin_comment: 'Husk logo på alle sider'

- model: companies.Company
pk: 2
Expand Down
38 changes: 38 additions & 0 deletions lego/apps/companies/migrations/0029_bdb_remove_admin_comment.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.0.10 on 2024-09-25 18:53

from django.db import migrations


def create_comment_with_old_admin_comment(apps, schema_editor):
Company = apps.get_model("companies", "Company")
Comment = apps.get_model("comments", "Comment")
CompanyContentType = apps.get_model("contenttypes", "ContentType").objects.get(
model="company"
)

# print(Comment.objects.first().content_object)

for c in Company.objects.all():
if c.admin_comment != None:
Comment.objects.create(
text="Autogenerert kommentar fra gammelt notat: \n" + c.admin_comment,
content_type=CompanyContentType,
object_id=c.id,
)


class Migration(migrations.Migration):

dependencies = [
('companies', '0028_alter_companyinterest_other_offers'),
('comments', '0008_alter_comment_created_by_alter_comment_updated_by'),
("contenttypes", "0002_remove_content_type_name")
]

operations = [
migrations.RunPython(create_comment_with_old_admin_comment),
migrations.RemoveField(
model_name="company",
name="admin_comment",
),
]
1 change: 0 additions & 1 deletion lego/apps/companies/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class Company(BasisModel):
company_type = models.CharField(max_length=200, blank=True)
website = models.URLField(blank=True)
address = models.CharField(max_length=200, blank=True)
admin_comment = models.CharField(max_length=100, blank=True)
active = models.BooleanField(default=True)
payment_mail = models.EmailField(max_length=100, blank=True)
comments = GenericRelation(Comment)
Expand Down
2 changes: 0 additions & 2 deletions lego/apps/companies/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ class Meta:
"name",
"semester_statuses",
"student_contact",
"admin_comment",
"active",
)

Expand Down Expand Up @@ -203,7 +202,6 @@ class Meta:
"content_target",
"semester_statuses",
"active",
"admin_comment",
"logo",
"files",
"company_contacts",
Expand Down

0 comments on commit cfa6fed

Please sign in to comment.