Exemplo n.º 1
0
class Committee(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    posts = db.relationship("CommitteePost", back_populates="committee")
    events = db.relationship("Event", back_populates="committee")
    logo = db.Column(db.String)
    description = db.Column(db.String)
    facebook_url = db.Column(db.String)
    instagram_url = db.Column(db.String)
    page_id = db.Column(db.Integer, db.ForeignKey("page.id"))
    page = db.relationship("Page", back_populates="committee")
    category_id = db.Column(db.Integer, db.ForeignKey('CommitteeCategory.id'))
    category = db.relationship("CommitteeCategory")

    def to_dict(self):
        posts = [post.to_dict() for post in self.posts]
        events = [event.to_dict() for event in self.events]

        if self.page != None:
            page = self.page.to_dict()
        else:
            page = None

        return {
            "id": self.id,
            "name": self.name,
            "posts": sorted(posts, key=lambda p: p["weight"], reverse=True),
            "logo": self.logo,
            "description": self.description,
            "facebookUrl": self.facebook_url if not RECEPTION_MODE else None,
            "instagramUrl": self.instagram_url if not RECEPTION_MODE else None,
            "page": page,
            "events": events,
        }

    def to_dict_without_page(self):
        posts = [post.to_dict() for post in self.posts]
        events = [event.to_dict() for event in self.events]

        return {
            "id": self.id,
            "name": self.name,
            "posts": sorted(posts, key=lambda p: p["weight"], reverse=True),
            "logo": self.logo,
            "description": self.description,
            "facebookUrl": self.facebook_url if not RECEPTION_MODE else None,
            "instagramUrl": self.instagram_url if not RECEPTION_MODE else None,
            "events": events,
        }

    def to_basic_dict(self):
        return {
            "id": self.id,
            "name": self.name,
            "logo": self.logo,
            "description": self.description,
            "facebookUrl": self.facebook_url if not RECEPTION_MODE else None,
            "instagramUrl": self.instagram_url if not RECEPTION_MODE else None,
            "pageSlug": self.page.slug if self.page else None
        }
Exemplo n.º 2
0
class MessageModel(db.Model):
    __tablename__ = "messages"
    id = db.Column(db.Integer, primary_key=True)
    message = db.Column(db.String(140))

    sender_id = db.Column(db.Integer,
                          db.ForeignKey("users.id"),
                          nullable=False)
    recipient_id = db.Column(db.Integer,
                             db.ForeignKey("users.id"),
                             nullable=False)

    recipient = db.relationship("UserModel", foreign_keys=[recipient_id])
    sender = db.relationship("UserModel", foreign_keys=[sender_id])

    def save_to_db(self):
        db.session.add(self)
        db.session.commit()

    def json(self):
        return {
            "id": self.id,
            "message": self.message,
            "sender_id": self.sender_id,
            "recipient_id": self.recipient_id,
        }

    @classmethod
    def find_recent_from(cls, recipient_id, sender_id):
        return (cls.query.filter_by(
            sender_id=sender_id, recipient_id=recipient_id).limit(100).all())

    @classmethod
    def find_recent(cls, recipient_id):
        return cls.query.filter_by(recipient_id=recipient_id).limit(100).all()
Exemplo n.º 3
0
class Event(db.Model):
    __tablename__ = "event"
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    title = db.Column(db.String, nullable=False)
    title_en = db.Column(db.String, nullable=True)
    date = db.Column(db.DateTime, default=datetime.datetime.utcnow)
    scheduled_date = db.Column(db.DateTime, default=None, nullable=True)
    draft = db.Column(db.Boolean, default=False)
    body = db.Column(db.Text, nullable=False)
    body_en = db.Column(db.Text, nullable=True)
    location = db.Column(db.String)
    committee_id = db.Column(db.Integer, db.ForeignKey('committee.id'))
    committee = db.relationship("Committee", back_populates="events")
    header_image = db.Column(
        db.String, default="static/posts/default.png"
    )  #can be changed if we get a default event picture
    tags = db.relationship("PostTag", secondary=events_tags)
    facebook_link = db.Column(db.String)
    event_date = db.Column(db.DateTime, default=datetime.datetime.utcnow())
    end_date = db.Column(db.DateTime,
                         default=datetime.datetime.utcnow() +
                         datetime.timedelta(hours=5))

    def to_dict(self):
        com = None
        if self.committee:
            com = self.committee.to_basic_dict()

        return {
            "id": self.id,
            "user_id": self.user_id,
            "title": {
                "se": self.title,
                "en": self.title_en
            },
            "date": self.date,
            "scheduled_date": self.scheduled_date,
            "draft": self.draft,
            "body": {
                "se": self.body,
                "en": self.body_en
            },
            "location": self.location,
            "header_image": self.header_image,
            "committee": com,
            "tags": [t.to_dict() for t in self.tags],
            "facebook_link": self.facebook_link,
            "event_date": self.event_date,
            "end_date": self.end_date
        }
Exemplo n.º 4
0
class Review(db.Model):
    """Class to create a Review class object"""

    __tablename__ = 'reviews'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), unique=True, nullable=False)
    description = db.Column(db.String(256), nullable=False)
    business = db.Column(db.Integer, db.ForeignKey('businesses.id'))
    created_by = db.Column(db.Integer, db.ForeignKey('users.id'))
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
    updated_at = db.Column(db.DateTime, default=db.func.current_timestamp(
    ), onupdate=db.func.current_timestamp())
    author = db.relationship("User")

    def __init__(self, name, description, business):
        self.name = name
        self.description = description
        self.business = business
        self.created_by = session["user_id"]

    def __repr__(self):
        return '<Review: {}>'.format(self.name)

    def review_as_dict(self):
        """Represent the review as a dict"""

        review = {r.name: getattr(self, r.name) for r in self.__table__.columns}
        review['author'] = self.author.first_name + ' ' + self.author.last_name
        return review
Exemplo n.º 5
0
class Log(db.Model):
    """Class for database changes logs"""

    __tablename__ = 'logs'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    action = db.Column(db.String(50), nullable=False)
    message = db.Column(db.String(256), nullable=False)
    table = db.Column(db.String(50), nullable=False)
    created_by = db.Column(db.Integer, db.ForeignKey('users.id'))
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
    author = db.relationship("User")

    def __init__(self, action, message, table, user_id):
        self.action = action
        self.message = message
        self.table = table
        self.created_by = user_id

    def __repr__(self):
        return '<Log: {}>'.format(self.message)

    def log_as_dict(self):
        """Represent the log as a dict"""

        log = {l.name: getattr(self, l.name) for l in self.__table__.columns}
        log['author'] = self.author.first_name + ' ' + self.author.last_name
        return log
Exemplo n.º 6
0
class User(UserMixin, db.Model):
    """Class to create a User class object"""

    __tablename__ = 'users'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    first_name = db.Column(db.String(50), nullable=False)
    last_name = db.Column(db.String(50), nullable=False)
    username = db.Column(db.String(50), nullable=False, unique=True)
    password_hash = db.Column(db.String(256), nullable=False)
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
    updated_at = db.Column(db.DateTime,
                           default=db.func.current_timestamp(),
                           onupdate=db.func.current_timestamp())
    businesses = db.relationship('Business',
                                 order_by='Business.id',
                                 cascade='all, delete-orphan')

    def __init__(self, first_name, last_name, username, password):
        self.first_name = first_name
        self.last_name = last_name
        self.username = username
        self.password_hash = generate_password_hash(password)

    def __repr__(self):
        return '<User: {}>'.format(self.username)

    def user_as_dict(self):
        """Represent the user as a dict"""

        return {u.name: getattr(self, u.name) for u in self.__table__.columns}
Exemplo n.º 7
0
class Category(db.Model):
    """Class to create a Category class object"""

    __tablename__ = 'categories'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), unique=True, nullable=False)
    description = db.Column(db.String(256), nullable=False)
    created_by = db.Column(db.Integer, db.ForeignKey('users.id'))
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
    updated_at = db.Column(db.DateTime,
                           default=db.func.current_timestamp(),
                           onupdate=db.func.current_timestamp())
    author = db.relationship("User")

    def __init__(self, name, description):
        self.name = name
        self.description = description
        self.created_by = session["user_id"]

    def __repr__(self):
        return '<Category: {}>'.format(self.name)

    def category_as_dict(self):
        """Represent the category as a dict"""

        category = {
            c.name: getattr(self, c.name)
            for c in self.__table__.columns
        }
        category[
            'author'] = self.author.first_name + ' ' + self.author.last_name
        return category
Exemplo n.º 8
0
class Business(db.Model):
    """Class to create a Business class object"""

    __tablename__ = 'businesses'

    id = db.Column(db.Integer, primary_key=True, autoincrement=True)
    name = db.Column(db.String(50), unique=True, nullable=False)
    description = db.Column(db.String(256), nullable=False)
    category = db.Column(db.Integer, db.ForeignKey('categories.id'))
    location = db.Column(db.Integer, db.ForeignKey('locations.id'))
    photo = db.Column(db.String(256))
    created_by = db.Column(db.Integer, db.ForeignKey('users.id'))
    created_at = db.Column(db.DateTime, default=db.func.current_timestamp())
    updated_at = db.Column(db.DateTime,
                           default=db.func.current_timestamp(),
                           onupdate=db.func.current_timestamp())
    reviews = db.relationship('Review',
                              order_by='Review.id',
                              cascade='all, delete-orphan')
    author = db.relationship("User")
    category_relationship = db.relationship("Category")
    location_relationship = db.relationship("Location")

    def __init__(self, name, description, category, location, photo):
        self.name = name
        self.description = description
        self.category = category
        self.location = location
        self.photo = photo
        self.created_by = session["user_id"]

    def __repr__(self):
        return '<Business: {}>'.format(self.name)

    def business_as_dict(self):
        """Represent the business as a dict"""

        business = {
            b.name: getattr(self, b.name)
            for b in self.__table__.columns
        }
        business[
            'author'] = self.author.first_name + ' ' + self.author.last_name
        business['category_name'] = self.category_relationship.name
        business['location_name'] = self.location_relationship.name
        return business
Exemplo n.º 9
0
class User(db.Model, UserMixin):
    id = db.Column(db.Integer, primary_key=True)
    email = db.Column(db.String(255), unique=True)
    password = db.Column(db.String(255))
    active = db.Column(db.Boolean())
    confirmed_at = db.Column(db.DateTime())
    roles = db.relationship("Role",
                            secondary=roles_users,
                            backref=db.backref("users", lazy="dynamic"))
class CommitteePostTerm(db.Model):
    __tablename__ = "committee_post_term"
    id = db.Column(db.Integer, primary_key=True)
    post_id = db.Column(db.Integer, db.ForeignKey('committee_post.id'))
    post = db.relationship("CommitteePost", back_populates="terms")
    start_date = db.Column(db.DateTime)
    end_date = db.Column(db.DateTime)
    user_id = db.Column(db.Integer, db.ForeignKey('user.id'))
    user = db.relationship("User", back_populates="post_terms")

    def to_dict(self):
        return {
            "id": self.id,
            "startDate": self.start_date.strftime("%Y-%m-%d"),
            "endDate": self.end_date.strftime("%Y-%m-%d"),
            "post": self.post.to_dict_without_terms(),
            "user": self.user.to_dict_without_terms(),
            "isCurrent": self.start_date < datetime.now() < self.end_date
        }
Exemplo n.º 11
0
class ArticleModel(db.Model, CRUDMixin):
    __tablename__ = 'api_article'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(80), nullable=False)
    description = db.Column(db.Text)

    categories = db.relationship('CategoryModel', secondary=api_category_article, lazy='subquery',
                             backref=db.backref('articles', lazy=True))

    def __repr__(self):
        return '<id {}>'.format(self.id)
Exemplo n.º 12
0
class Album(db.Model):
    __tablename__ = "albums"
    albumId = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    creationDate = db.Column(db.DateTime, default=datetime.datetime.now)
    lastEdit = db.Column(db.DateTime, default=datetime.datetime.now)
    receptionAppropriate = db.Column(db.Boolean)
    images = db.relationship("Image", secondary=imageAssociation)
    videos = db.relationship("Video", secondary=video_playlist_table)
    date = db.Column(db.DateTime)

    def to_dict(self):
        return {
            "id": self.albumId,
            "title": self.title,
            "creationDate": self.creationDate,
            "lastEdit": self.lastEdit,
            "receptionAppropriate": self.receptionAppropriate,
            "images": [image.to_dict() for image in self.images],
            "videos": [video.to_dict() for video in self.videos],
            "date": self.date
        }
Exemplo n.º 13
0
class CommitteeCategory(db.Model):
    __tablename__ = 'CommitteeCategory'

    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String, nullable=False, unique=True)
    email = db.Column(db.String, nullable=True)
    weight = db.Column(db.Integer, default=1)
    committees = db.relationship("Committee")

    def to_dict(self):
        return {
            "id": self.id,
            "title": self.title,
            "email": self.email,
            "weight": self.weight
        }
Exemplo n.º 14
0
class Video(db.Model):
    __tablename__ = 'video'
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    mux_asset_id = db.Column(db.String)
    mux_playback_id = db.Column(db.String)
    uploaded_at = db.Column(db.DateTime, default=datetime.datetime.now)
    requires_login = db.Column(db.Boolean, default=False)
    albums = db.relationship("Album", secondary=video_playlist_table)

    def to_dict(self):
        return {
            "id": self.id,
            "title": self.title,
            "url": "https://stream.mux.com/" + self.mux_playback_id + ".m3u8",
            "thumbnail":
            "https://image.mux.com/" + self.mux_playback_id + "/thumbnail.jpg",
            "uploadedAt": self.uploaded_at,
            "requiresLogin": self.requires_login,
            "albums": [album.albumId for album in self.albums]
        }
Exemplo n.º 15
0
class PageRevision(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    timestamp = db.Column(db.DateTime, default=datetime.datetime.now)
    revision_type = db.Column(db.Enum(PageRevisionType))
    author_id = db.Column(db.Integer, db.ForeignKey("user.id"))
    author = db.relationship("User")
    title_sv = db.Column(db.String)
    title_en = db.Column(db.String)
    content_sv = db.Column(db.String)
    content_en = db.Column(db.String)
    image = db.Column(db.String)
    page_id = db.Column(db.Integer, db.ForeignKey("page.id"))
    published = db.Column(db.Boolean, default=False)

    def to_dict(self):
        return {
            "id":
            self.id,
            "timestamp":
            self.timestamp,
            "type":
            self.revision_type.name,
            "author":
            self.author.to_dict_without_terms()
            if self.author != None else None,
            "title_sv":
            self.title_sv,
            "title_en":
            self.title_en,
            "image":
            self.image if not RECEPTION_MODE else None,
            "content_sv":
            self.content_sv,
            "content_en":
            self.content_en,
            "published":
            self.published
        }
Exemplo n.º 16
0
class Post(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String, nullable=False)
    title_en = db.Column(db.String, nullable=True)
    date = db.Column(db.DateTime, default=datetime.utcnow)
    scheduled_date = db.Column(db.DateTime, default=None, nullable=True)
    draft = db.Column(db.Boolean, default=False)
    header_image = db.Column(
        db.String,
        default="https://api.medieteknik.com/static/posts/default.png")
    body = db.Column(db.String, nullable=False)
    body_en = db.Column(db.String, nullable=True)
    user_id = db.Column(db.Integer, db.ForeignKey("user.id"), nullable=False)
    committee_id = db.Column(db.Integer,
                             db.ForeignKey("committee.id"),
                             nullable=True)
    tags = db.relationship("PostTag", secondary=posts_tags)

    def to_dict(self):
        return {
            "id": self.id,
            "title": {
                "se": self.title,
                "en": self.title_en
            },
            "date": self.date,
            "scheduled_date": self.scheduled_date,
            "draft": self.draft,
            "header_image": self.header_image,
            "body": {
                "se": self.body,
                "en": self.body_en
            },
            "user_id": self.user_id,
            "committee_id": self.committee_id,
            "tags": [tag.id for tag in self.tags]
        }
Exemplo n.º 17
0
class Document(db.Model):
    __tablename__ = "documents"
    itemId = db.Column(db.Integer, primary_key=True)
    title = db.Column(db.String)
    title_en = db.Column(db.String)
    tags = db.relationship("DocumentTags")
    date = db.Column(db.Date, nullable=False)
    fileName = db.Column(db.String)
    thumbnail = db.Column(db.String)

    def to_dict(self):
        return {
            "id": self.itemId,
            "title": {
                "se": self.title,
                "en": self.title_en
            },
            "tags": [res.tagId for res in self.tags],
            "fullTags": [res.serialize() for res in self.tags],
            "filename": self.fileName,
            "date":
            self.date.strftime("%Y-%m-%d") if self.date is not None else None,
            "thumbnail": self.thumbnail
        }
Exemplo n.º 18
0
class Page(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    slug = db.Column(db.String, unique=True)
    committee = db.relationship("Committee",
                                back_populates="page",
                                uselist=False)
    revisions = db.relationship("PageRevision",
                                backref="page",
                                order_by=lambda: PageRevision.timestamp.desc())

    def latest_published_revision(self):
        return next(
            (revision for revision in self.revisions if revision.published),
            None)

    def is_editable_by(self, user):
        if self.committee == None:
            return False

        for term in user.post_terms:
            committee_id = term.post.committee_id
            if self.committee.id == committee_id:
                return True
        return False

    def to_dict(self):
        current = self.latest_published_revision()
        published = current != None
        committee = self.committee.to_dict_without_page(
        ) if self.committee != None else None

        if published:
            title_sv = current.title_sv
            title_en = current.title_en
            content_sv = current.content_sv
            content_en = current.content_en
            image = current.image
            author = current.author.to_dict(
            ) if current.author != None else None
            updated = current.timestamp
        else:
            title_sv = None
            title_en = None
            content_sv = None
            content_en = None
            image = None
            author = None
            updated = None

        return {
            "id": self.id,
            "slug": self.slug,
            "committee": committee,
            "title_sv": title_sv,
            "title_en": title_en,
            "content_sv": content_sv,
            "content_en": content_en,
            "image": image if not RECEPTION_MODE else None,
            "author": author,
            "revisions": [revision.to_dict() for revision in self.revisions],
            "published": published,
            "updated": updated
        }
Exemplo n.º 19
0
class User(db.Model):
    __tablename__ = 'User'

    id = db.Column(db.String(100), primary_key=True)
    username = db.Column(db.String(80))
    password = db.Column(db.String(100))
    email = db.Column(db.String(100))
    photoURL = db.Column(db.String, default=_photoURL)
    allowed_usage = db.Column(db.Integer)
    ftl = db.Column(db.Boolean, default=True)
    created_at = db.Column(db.DateTime,
                           nullable=False,
                           default=datetime.utcnow)
    deleted_at = db.Column(db.DateTime, nullable=True)
    files = db.relationship('File', backref='uploader')
    badges = db.relationship('Badges', backref='creator')
    permissions = db.relationship('Permissions',
                                  backref=db.backref('user_permissions'),
                                  lazy='dynamic')
    siteAdmin = db.Column(db.Boolean, default=False)
    last_login_ip = db.Column(db.String, nullable=True)
    last_login_date = db.Column(db.DateTime, nullable=True)

    def __init__(self, id_, username, password, email, photoURL=None):
        self.id = id_
        self.username = username
        self.allowed_usage = 200
        if password:
            self.password = generate_password_hash(password)
        self.email = email
        if photoURL:
            self.photoURL = photoURL

    def create_site_admin(self):
        self.siteAdmin = True
        self.save_to_db()

    def save_to_db(self):
        db.session.add(self)
        try:
            db.session.commit()
        except Exception as e:
            db.session.rollback()
            db.session.flush()
            print(e)

    def delete_user(self):
        db.session.delete(self)
        try:
            db.session.commit()
        except Exception as e:
            db.session.rollback()
            db.session.flush()
            print(e)

    @classmethod
    def getUser(cls, user_id=None, username=None, email=None):
        if user_id:
            return cls.query.filter_by(id=user_id).first()
        if username:
            return cls.query.filter_by(username=username).first()
        if email:
            return cls.query.filter_by(email=email).first()
class CommitteePost(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String)
    officials_email = db.Column(db.String)
    committee_id = db.Column(db.Integer, db.ForeignKey('committee.id'))
    committee = db.relationship("Committee", back_populates="posts")
    is_official = db.Column(db.Boolean)
    terms = db.relationship("CommitteePostTerm", back_populates="post")
    weight = db.Column(db.Integer, default=1)

    def soft_hyphenate(self, name):
        words = [
            "ansvarig", "skyddsombud", "ordförande", "frågor", "ombud",
            "ledare"
        ]
        hyphenated = name
        for word in words:
            hyphenated = hyphenated.replace(word, "&#173;" + word, 1)
        return hyphenated

    def current_terms(self):
        date = datetime.now()
        terms = CommitteePostTerm.query.filter(
            CommitteePostTerm.post_id == self.id).filter(
                and_(CommitteePostTerm.start_date <= date,
                     CommitteePostTerm.end_date >= date)).all()

        return terms

    def new_term(self, start_date, end_date):
        term = CommitteePostTerm()
        term.post = self
        term.start_date = start_date
        term.end_date = end_date
        return term

    def to_dict(self):
        terms = []
        for term in self.current_terms():
            terms.append({
                "id": term.id,
                "startDate": term.start_date,
                "endDate": term.end_date,
                "user": term.user.to_dict_without_terms()
            })

        return {
            "id": self.id,
            "name": self.name,
            "email": self.officials_email,
            "committeeId": self.committee_id,
            "committeeCategory": self.committee.category.to_dict(),
            "isOfficial": self.is_official,
            "currentTerms": terms,
            "weight": self.weight
        }

    def to_dict_without_terms(self, hyphenate=False):
        return {
            "id": self.id,
            "name": self.soft_hyphenate(self.name) if hyphenate else self.name,
            "email": self.officials_email,
            "committeeId": self.committee_id,
            "committeeCategory": self.committee.category.to_dict(),
            "isOfficial": self.is_official,
            "weight": self.weight
        }

    def to_dict_with_all_terms(self):
        terms = []
        current_terms = self.current_terms()
        for term in self.terms:
            terms.append({
                "id": term.id,
                "startDate": term.start_date,
                "endDate": term.end_date,
                "user": term.user.to_dict_without_terms(),
                "current": term in current_terms
            })

        return {
            "id": self.id,
            "name": self.name,
            "email": self.officials_email,
            "committeeId": self.committee_id,
            "committeeCategory": self.committee.category.to_dict(),
            "isOfficial": self.is_official,
            "terms": terms,
            "weight": self.weight
        }
Exemplo n.º 21
0
class User(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    kth_id = db.Column(db.String, unique=True)
    email = db.Column(db.String)
    profile_picture = db.Column(db.String,
                                default="/static/profiles/default.png")
    first_name = db.Column(db.String)
    last_name = db.Column(db.String)
    frack_name = db.Column(db.String, nullable=True)
    kth_year = db.Column(db.Integer)
    linkedin = db.Column(db.String, nullable=True)
    facebook = db.Column(db.String, nullable=True)
    alumni = db.Column(db.Boolean, default=False)
    post_terms = db.relationship("CommitteePostTerm",
                                 back_populates="user",
                                 lazy='dynamic')
    is_admin = db.Column(db.Boolean, default=False)

    def to_dict(self):
        terms = []

        for term in self.post_terms:
            terms.append({
                "post": term.post.to_dict_without_terms(),
                "startDate": term.start_date,
                "endDate": term.end_date
            })

        return {
            "id":
            self.id,
            "email":
            self.email,
            "kthId":
            self.kth_id,
            "profilePicture":
            self.profile_picture
            if not RECEPTION_MODE else "/static/profiles/default.png",
            "firstName":
            self.frack_name if (RECEPTION_MODE and self.frack_name is not None)
            else self.first_name,
            "lastName":
            "" if (RECEPTION_MODE
                   and self.frack_name is not None) else self.last_name,
            "frackName":
            self.frack_name,
            "kthYear":
            self.kth_year,
            "linkedin":
            self.linkedin if not RECEPTION_MODE else None,
            "facebook":
            self.facebook if not RECEPTION_MODE else None,
            "committeePostTerms":
            terms,
            "alumni":
            self.alumni,
            "isAdmin":
            self.is_admin
        }

    def to_dict_without_terms(self):
        return {
            "id":
            self.id,
            "email":
            self.email,
            "kthId":
            self.kth_id,
            "profilePicture":
            self.profile_picture
            if not RECEPTION_MODE else "/static/profiles/default.png",
            "firstName":
            self.frack_name if (RECEPTION_MODE and self.frack_name is not None)
            else self.first_name,
            "lastName":
            "" if (RECEPTION_MODE
                   and self.frack_name is not None) else self.last_name,
            "frackName":
            self.frack_name,
            "kthYear":
            self.kth_year,
            "linkedin":
            self.linkedin if not RECEPTION_MODE else None,
            "facebook":
            self.facebook if not RECEPTION_MODE else None,
            "alumni":
            self.alumni,
            "isAdmin":
            self.is_admin
        }