Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module/corporate event #1039

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## corporate-event backend configuration and information

## Module description

This module is a complete corporate event app template.

## Features

- [x] This module includes migrations.
- [ ] This module includes environment variables.
- [x] This module requires manual configurations.
- [ ] This module can be configured with module options.

## Environment variables

```bash
ADMIN_EMAIL_RECEIVERS="[email protected],[email protected]"
```


## API details

Detailed API spec is available [here](./event_module_collection.json) in postman collection
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from django.contrib import admin

from .models import Session, UserSession, Activities, UserActivities, ConnectProfile, UserConnectRequest, \
AboutTeamAndBoardMember, OfferigsPage, SessionAttachment, ActivitiesAttachment, MetaLink


class UserSessionAdmin(admin.TabularInline):
model = UserSession
extra = 0


class SessionAttachmentAdmin(admin.TabularInline):
model = SessionAttachment
extra = 0


class SessoinAdmin(admin.ModelAdmin):
list_display = ['title', 'date', 'start_time', 'session_number', 'sort']
list_filter = ['date']
inlines = [
SessionAttachmentAdmin,
UserSessionAdmin,
]

# Register your models here.

class UserActivitiesAdmin(admin.TabularInline):
model = UserActivities
extra = 0


class ActivitiesAttachmentAdmin(admin.TabularInline):
model = ActivitiesAttachment
extra = 0


class ActivitiesAdmin(admin.ModelAdmin):
list_display = ['title', 'start_time', 'description']
inlines = [
ActivitiesAttachmentAdmin,
UserActivitiesAdmin,
]

class ConnectProfileAdmin(admin.ModelAdmin):
list_display = ['user', 'designation', 'company']


class UserConnectRequestAdmin(admin.ModelAdmin):
list_display = ['requester', 'requestee', 'status']
list_filter = ['status']


class AboutTeamAndBoardMemberAdmin(admin.ModelAdmin):
list_display = ['select', 'connect_user']
list_filter = ['select']


class OfferigsPageAdmin(admin.ModelAdmin):
list_display = ['title', 'slug', 'sort', 'is_active']


admin.site.register(Session, SessoinAdmin)
admin.site.register(Activities, ActivitiesAdmin)
admin.site.register(ConnectProfile, ConnectProfileAdmin)
admin.site.register(UserConnectRequest, UserConnectRequestAdmin)
admin.site.register(AboutTeamAndBoardMember, AboutTeamAndBoardMemberAdmin)
admin.site.register(OfferigsPage, OfferigsPageAdmin)
admin.site.register(MetaLink)
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
from allauth.account import app_settings as allauth_settings
from allauth.account.adapter import get_adapter
from allauth.account.forms import ResetPasswordForm
from allauth.account.utils import setup_user_email
from allauth.utils import email_address_exists, generate_unique_username
from django.contrib.auth import get_user_model
from django.http import HttpRequest
from django.utils.translation import ugettext_lazy as _
from rest_framework import serializers

from modules.corporate_event.corporate_event.models import OfferigsPage, Activities, UserConnectRequest, ConnectProfile, AboutTeamAndBoardMember, Session, \
UserSession, SessionAttachment, ActivitiesAttachment, UserActivities

from home.api.v1.serializers import UserSerializer

class ActivitiesAttachmentSerializer(serializers.ModelSerializer):
class Meta:
model = ActivitiesAttachment
fields = '__all__'

class SessionAttachmentSerializer(serializers.ModelSerializer):
class Meta:
model = SessionAttachment
fields = '__all__'


class UserSessionSerializer(serializers.ModelSerializer):
attachments = serializers.SerializerMethodField()

def get_attachments(self, obj):
return SessionAttachmentSerializer(obj.session_attachment.all(), many=True, context=self.context).data

class Meta:
model = Session
fields = [
'id', 'title', 'date', 'start_time', 'session_number', 'image', 'sort', 'description', 'attachments'
]
extra_kwargs = {
"user": {"required": False}
}


class EventsActivitySerializer(serializers.ModelSerializer):
attachments = serializers.SerializerMethodField()

def get_attachments(self, obj):
return ActivitiesAttachmentSerializer(obj.activity_attachment.all(), many=True, context=self.context).data

class Meta:
model = Activities
fields = '__all__'


class UserRequestSerializer(serializers.ModelSerializer):
class Meta:
model = UserConnectRequest
fields = '__all__'
extra_kwargs = {
"requester": {"required": False}
}


class ConnectProfileSerializer(serializers.ModelSerializer):
user = UserSerializer(read_only=True)

class Meta:
model = ConnectProfile
fields = '__all__'


class AboutTeamAndBoardSerializer(serializers.ModelSerializer):
connect_user = ConnectProfileSerializer(read_only=True)

class Meta:
model = AboutTeamAndBoardMember
fields = ['select', 'connect_user']
ordering = ['connect_user__user__last_name']


class OfferigsPageSerializer(serializers.ModelSerializer):

class Meta:
model = OfferigsPage
fields = '__all__'


class HomeSessionSerializer(serializers.ModelSerializer):
start_time = serializers.TimeField(format="%I:%M %p", required=False, source='session.start_time')
title = serializers.CharField(required=False, source='session.title')
description = serializers.CharField(required=False, source='session.description')
image = serializers.ImageField(required=False, source='session.image')
type = serializers.SerializerMethodField()
attachments = serializers.SerializerMethodField()
start_time_stamp = serializers.SerializerMethodField()

def get_start_time_stamp(self, obj):
return obj.session.start_time

def get_type(self, obj):
return "session"

def get_attachments(self, obj):
all_session_attachments = self.context.get('all_session_attachments')
session_id = obj.session.id
if not all_session_attachments:
all_session_attachments = obj.session.session_attachment.all()
return SessionAttachmentSerializer(
all_session_attachments.filter(session_id=session_id), many=True,
context=self.context
).data

class Meta:
model = UserSession
fields = '__all__'




class HomeActivitiesSerializer(serializers.ModelSerializer):
start_time = serializers.TimeField(format="%I:%M %p", required=False, source='activity.start_time')
title = serializers.CharField(required=False, source='activity.title')
description = serializers.CharField(required=False, source='activity.description')
image = serializers.ImageField(required=False, source='activity.image')
type = serializers.SerializerMethodField()
attachments = serializers.SerializerMethodField()
start_time_stamp = serializers.SerializerMethodField()

def get_type(self, obj):
return "activity"

def get_start_time_stamp(self, obj):
return obj.activity.start_time

def get_attachments(self, obj):
all_activity_attachments = self.context.get('all_activity_attachments')
activity_id = obj.activity.id
if not all_activity_attachments:
all_activity_attachments = obj.activity.activity_attachment.all()
return ActivitiesAttachmentSerializer(
all_activity_attachments.filter(activity_id=activity_id), many=True,
context=self.context
).data

class Meta:
model = UserActivities
fields = '__all__'

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from django.urls import path, include
from rest_framework.routers import DefaultRouter

from .viewsets import (
UserSessionViewset,
SessionActivitiesViewset,
HomeViewSets,
UserConnectViewSet,
UserRequestViewSet,
AboutTeamAndBoardViewSet,
confirm_view,
OfferigsPageViewSet,
MetaLinkAPIView
)

router = DefaultRouter()
router.register("user-session", UserSessionViewset, basename="user-session")
router.register("session/activity", SessionActivitiesViewset, basename="activities")
router.register("home", HomeViewSets, basename="home")
router.register("connect", UserConnectViewSet, basename="connect")
router.register("connect/accept", UserRequestViewSet, basename="connect-accept")
router.register("board-team", AboutTeamAndBoardViewSet, basename="board-team")
router.register("offerings", OfferigsPageViewSet, basename="offerings")


urlpatterns = [
path("", include(router.urls)),
path('confirm/', confirm_view, name='confirm_view'),
path('meta_link/', MetaLinkAPIView.as_view(), name='meta_link')

]
Loading
Loading