Exemple #1
0
    def get(self):
        user = users.get_current_user()
        user_profile = User.query(User.email == user.email()).get()

        params = {"user_profile": user_profile}

        return self.render_template("user_profile.html", params=params)
Exemple #2
0
    def post(self, user_profile_id):
        user_profile = User.get_by_id(int(user_profile_id))

        first_name = self.request.get("first_name")
        last_name = self.request.get("last_name")
        avatar = self.request.get("avatar")

        bday_day = self.request.get("bday_day")
        bday_month = self.request.get("bday_month")
        bday_year = self.request.get("bday_year")

        now = datetime.now()

        bday_date = bday_day + bday_month + str(now.year)

        datetime_object = datetime.strptime(bday_date, '%d%m%Y')

        bday_age = int(now.year) - int(bday_year) - 1
        if now > datetime_object:
            bday_age = int(now.year) - int(bday_year)

        if now > datetime_object:
            str_datetime_object = datetime.strftime(datetime_object.date(), '%d%m%Y')
            year = int(str_datetime_object[-4:]) + 1
            bday_date_new = bday_day + bday_month + str(year)
            datetime_object = datetime.strptime(bday_date_new, '%d%m%Y')

        if not avatar:
            avatar = "https://s21.postimg.org/bu6oqrxg7/man.png"

        User.edit_profile(user_profile=user_profile,
                          first_name=first_name,
                          last_name=last_name,
                          bday_date=datetime_object,
                          bday_year=int(bday_year),
                          bday_age=bday_age,
                          avatar=avatar)

        return self.redirect_to("user-profile")
Exemple #3
0
    def post(self):
        user = users.get_current_user()
        user_profile = User.query(User.email == user.email()).get()
        first_name = self.request.get("first_name")
        last_name = self.request.get("last_name")
        avatar = self.request.get("avatar")

        bday_day = self.request.get("bday_day")
        bday_month = self.request.get("bday_month")
        bday_year = self.request.get("bday_year")

        now = datetime.now()

        bday_date = bday_day + bday_month + str(now.year)

        datetime_object = datetime.strptime(bday_date, '%d%m%Y')

        bday_age = int(now.year) - int(bday_year) - 1
        if now > datetime_object:
            bday_age = int(now.year) - int(bday_year)

        if now > datetime_object:
            str_datetime_object = datetime.strftime(datetime_object.date(),
                                                    '%d%m%Y')
            year = int(str_datetime_object[-4:]) + 1
            bday_date_new = bday_day + bday_month + str(year)
            datetime_object = datetime.strptime(bday_date_new, '%d%m%Y')

        if avatar:
            Bday.add_bday(first_name=first_name,
                          last_name=last_name,
                          avatar=avatar,
                          date=datetime_object,
                          bday_age=bday_age,
                          bday_year=int(bday_year),
                          user_email=user_profile.email)
        else:
            avatar_url = "https://s21.postimg.org/bu6oqrxg7/man.png"
            Bday.add_bday(first_name=first_name,
                          last_name=last_name,
                          avatar=avatar_url,
                          date=datetime_object,
                          bday_age=bday_age,
                          bday_year=int(bday_year),
                          user_email=user_profile.email)

            return self.redirect_to("bday-add")
Exemple #4
0
    def render_template(self, view_filename, params=None):
        if not params:
            params = {}

        user = users.get_current_user()

        if user:
            params["user"] = User.get_or_create(user.email())
            params["logout_url"] = users.create_logout_url("/")

            self.response.set_cookie(key="bday-cookie", value="accepted")

        else:
            params["login_url"] = users.create_login_url("/")

        csrf_token = str(uuid.uuid4())  # convert UUID to string
        memcache.add(key=csrf_token, value=True, time=600)
        params["csrf_token"] = csrf_token

        template = jinja_env.get_template(view_filename)
        return self.response.out.write(template.render(params))
Exemple #5
0
    def post(self):
        user = users.get_current_user()
        user_profile = User.query(User.email == user.email()).get()

        event_name = self.request.get("event_name")
        location = self.request.get("location")
        avatar = self.request.get("avatar")

        event_day = self.request.get("event_day")
        event_month = self.request.get("event_month")
        event_year = self.request.get("event_year")
        event_hour = self.request.get("event_hour")
        event_minute = self.request.get("event_minute")

        event_date = event_day + event_month + event_year + event_hour + event_minute
        datetime_object = datetime.strptime(event_date, '%d%m%Y%H%M')

        Event.add_event(event_name=event_name,
                        location=location,
                        avatar=avatar,
                        date=datetime_object,
                        user_email=user_profile.email)

        return self.redirect_to("event-add")
Exemple #6
0
    def post(self):
        user = users.get_current_user()
        user_profile = User.query(User.email == user.email()).get()

        anniversary_name = self.request.get("anniversary_name")
        avatar = self.request.get("avatar")

        anniversary_day = self.request.get("anniversary_day")
        anniversary_month = self.request.get("anniversary_month")
        anniversary_year = self.request.get("anniversary_year")

        now = datetime.now()

        anniversary_date = anniversary_day + anniversary_month + str(now.year)
        datetime_object = datetime.strptime(anniversary_date, '%d%m%Y')

        anniversary_age = int(now.year) - int(anniversary_year) - 1
        if now > datetime_object:
            anniversary_age = int(now.year) - int(anniversary_year)

        if now > datetime_object:
            str_datetime_object = datetime.strftime(datetime_object.date(),
                                                    '%d%m%Y')
            year = int(str_datetime_object[-4:]) + 1
            anniversary_date_new = anniversary_day + anniversary_month + str(
                year)
            datetime_object = datetime.strptime(anniversary_date_new, '%d%m%Y')

        Anniversary.add_anniversary(anniversary_name=anniversary_name,
                                    date=datetime_object,
                                    anniversary_year=int(anniversary_year),
                                    anniversary_age=int(anniversary_age),
                                    user_email=user_profile.email,
                                    avatar=avatar)

        return self.redirect_to("anniversary-add")
Exemple #7
0
    def get(self, user_profile_id):
        user_profile = User.get_by_id(int(user_profile_id))

        params = {"user_profile": user_profile}

        return self.render_template("user_profile_edit.html", params=params)