Beispiel #1
0
    def deserialize(self,ser):
        ser_created=functions.date_deserialize(ser["created"])
        defaults={}
        for k in [ "code_name",
	           "name",
	           "version",
	           "language",
	           "platform",
	           "user_agent",
	           "cookies_enabled",
	           "timezone",
	           "iso_timestamps",
                   "screen_width",
                   "screen_height",
                   "screen_color_depth",
                   "screen_pixel_depth",
                   "screen_available_height",
                   "screen_available_width",
                   "viewport_height",
                   "viewport_width",
	           "luxon_intl",
	           "luxon_intl_tokens",
	           "luxon_zones",
	           "luxon_relative" ]:
            defaults[k]=ser[k]

        obj,created=self.update_or_create(session_key=ser["session_key"],
                                          created=ser_created,
                                          defaults=defaults)
        if created:
            obj.created=ser_created
            obj.save()
        return obj
Beispiel #2
0
 def deserialize(self, ser):
     defaults = {
         "text": ser["text"],
         "created": functions.date_deserialize(ser["created"]),
     }
     obj, created = self.update_or_create(version=ser["version"],
                                          defaults=defaults)
     if created:
         obj.created = defaults["created"]
         obj.save()
     return obj
Beispiel #3
0
    def deserialize(self, ser):
        ser_created = functions.date_deserialize(ser["created"])
        ser_created_by = User.objects.deserialize(ser["created_by"])
        ser_last_modified_by = User.objects.deserialize(
            ser["last_modified_by"])
        defaults = {
            "publishing_date":
            functions.date_deserialize(ser["publishing_date"]),
            "content": ser["content"],
            "visible": ser["visible"],
        }

        obj, created = self.update_or_create(title=ser["title"],
                                             defaults=defaults)
        if created:
            obj.created = ser_created
            obj.created_by = ser_created_by
            obj.last_modified_by = ser_last_modified_by
            obj.save()

        return obj
Beispiel #4
0
 def deserialize(self, ser):
     ser = ser.copy()
     if "groups" in ser:
         groups = ser["groups"]
         del (ser["groups"])
     else:
         groups = []
     if "date_joined" in ser:
         ser["date_joined"] = functions.date_deserialize(ser["date_joined"])
     if "last_login" in ser:
         ser["last_login"] = functions.date_deserialize(ser["last_login"])
     try:
         user = self.clean_and_create_user(**ser)
     except ValidationError as e:
         if "username" in e.error_dict:
             user = self.get(username=ser["username"])
         elif "email" in e.error_dict:
             user = self.get(email=ser["email"])
         else:
             raise e
     for name in groups:
         grp = Group.objects.get(name=name)
         user.groups.add(grp)
     return user