Example #1
0
    def bl_create():
        Setting.objects.create(name='shift_assignment_time',
                               value=Setting._dumps({"hours": 1}))

        Setting.objects.create(name='shift_edition_time',
                               value=Setting._dumps({"hours": 12}))

        Setting.objects.create(name='allowed_positions',
                               value=Setting._dumps({
                                   "boss": 2,
                                   "laborant": 2
                               }))
Example #2
0
    def put(self, request):
        setting_data = json.loads(request.body)
        setting = Setting.objects.get(id=int(setting_data['id']))
        setting.verbose_name = setting_data.get('value', setting.verbose_name)
        setting.value = Setting._dumps(setting_data['value'])
        setting.save()

        return JsonResponse({"status": 1})
Example #3
0
    def post(self, request):
        setting_data = json.loads(request.body)
        Setting.objects.create(value=Setting._dumps(setting_data['value']),
                               name=setting_data['name'],
                               employee=request.user.employee,
                               object_id=int(setting_data['scope']['id'])
                               if setting_data.get('scope', None) else None,
                               content_type=ContentType.objects.get(
                                   id=int(setting_data['content_type']))
                               if setting_data.get('scope', None) else None)

        return JsonResponse({"status": 1})