Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
albertoleoncio committed Jan 11, 2025
1 parent 1591de1 commit af16314
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
23 changes: 23 additions & 0 deletions orgs/migrations/0009_organization_email_organization_website.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.2.11 on 2025-01-11 17:38

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('orgs', '0008_organization_tag_diff'),
]

operations = [
migrations.AddField(
model_name='organization',
name='email',
field=models.EmailField(blank=True, help_text='The email address of the organization.', max_length=254, null=True),
),
migrations.AddField(
model_name='organization',
name='website',
field=models.URLField(blank=True, help_text='The URL of the organization website.', null=True),
),
]
8 changes: 8 additions & 0 deletions orgs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class Organization(models.Model):
message='Invalid URL format. The format should be https://meta.wikimedia.org/wiki/PageName'
)]
)
email = models.EmailField(
blank=True, null=True,
help_text='The email address of the organization.',
)
website = models.URLField(
blank=True, null=True,
help_text='The URL of the organization website.',
)
mastodon = models.URLField(
blank=True, null=True,
help_text='The URL of the organization Mastodon account.',
Expand Down
12 changes: 12 additions & 0 deletions orgs/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@


class OrganizationSerializer(serializers.ModelSerializer):
projects = serializers.SerializerMethodField()
events = serializers.SerializerMethodField()

class Meta:
model = Organization
fields = '__all__'
read_only_fields = ['creation_date']

def get_projects(self, obj):
from projects.models import ProjectMember
return ProjectMember.objects.filter(organization=obj, projectmemberacceptance__accepted=True).values_list('project', flat=True)

def get_events(self, obj):
from events.models import EventOrganizations
return EventOrganizations.objects.filter(organization=obj).values_list('event', flat=True)



class OrganizationTypeSerializer(serializers.ModelSerializer):
class Meta:
Expand Down

0 comments on commit af16314

Please sign in to comment.