# Path: antioch/core/models.py
# class URLField(models.CharField):
# class Object(models.Model):
#     class Meta:
# class Relationship(models.Model):
#     class Meta:
# class Observation(models.Model):
#     class Meta:
# class Alias(models.Model):
#     class Meta:
# class Repository(models.Model):
#     class Meta:
# class Verb(models.Model):
#     class Meta:
# class VerbName(models.Model):
#     class Meta:
# class Property(models.Model):
#     class Meta:
# class Permission(models.Model):
#     class Meta:
# class Access(models.Model):
#     class Meta:
# class Player(models.Model):
#     class Meta:
# class Task(models.Model):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def annotated(self):
#     def name(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def actor(self):
#     def entity(self):
#     def origin(self):
#     def __str__(self):
#     def __str__(self):
#     def is_authenticated(self):
#     def is_active(self):
#     def is_staff(self):
#     def is_superuser(self):
#     def has_module_perms(self, app):
#     def has_perm(self, perm):
#     def email(self):
# 
# Path: antioch/plugins/editors/tasks.py
# def openeditor(user_id, object_id, type, name):
# def openaccess(user_id, object_id, type, name):
# def modifyobject(user_id, object, name, location, parents, owner):
# def modifyverb(user_id, object_id, verb_id, names, code, ability, method, owner):
# def removeverb(user_id, object_id, verb_name):
# def removeproperty(user_id, object_id, property_name):
# def modifyproperty(user_id, object_id, property_id, name, value, type, owner):
# def modifyaccess(user_id, object_id, type, access):
# def getobjectdetails(user_id, object_id):
# 
# Path: antioch/plugins/editors/forms.py
# class AuthenticatedModelForm(forms.ModelForm):
# class ObjectForm(AuthenticatedModelForm):
#     class Meta:
# class PropertyForm(AuthenticatedModelForm):
#     class Meta:
# class VerbForm(AuthenticatedModelForm):
#     class Meta:
# class AccessForm(forms.ModelForm):
#     class Meta:
#     def __init__(self, user_id=None, *args, **kwargs):
#     def clean_location(self):
#     def clean_owner(self):
#     def clean_parents(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):
#     def clean_owner(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):
#     def clean_owner(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):


import json
from django import template, shortcuts, http
from django.conf import settings
from django.views.generic import UpdateView
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from django.forms.models import modelformset_factory
from antioch.core import models
from antioch.plugins.editors import tasks, forms
class AjaxFormMixin(object):
    def form_valid(self, form):
        try:
            form.save()
            return http.HttpResponse(SUCCESS_JSON, content_type="application/json")
        except Exception as e:
            return http.HttpResponse(EXCEPTION_JSON % e, content_type="application/json", status=500)
    
    def form_invalid(self, form):
        return http.HttpResponse(get_errors_json(form.errors), content_type="application/json", status=422)

class EditorFormView(LoginRequiredMixin, AjaxFormMixin, UpdateView):
    def get_form_kwargs(self):
        kwargs = super(EditorFormView, self).get_form_kwargs()
        kwargs['user_id'] = self.request.user.avatar.id
        return kwargs
    
class ObjectEditorFormView(EditorFormView):
    template_name = 'object-editor.html'
    form_class = forms.ObjectForm
    model = models.Object
    
class PropertyEditorFormView(EditorFormView):
    template_name = 'property-editor.html'
    form_class = forms.PropertyForm
    model = models.Property
    
class VerbEditorFormView(EditorFormView):
    template_name = 'verb-editor.html'
    form_class = forms.VerbForm

# Path: antioch/core/models.py
# class URLField(models.CharField):
# class Object(models.Model):
#     class Meta:
# class Relationship(models.Model):
#     class Meta:
# class Observation(models.Model):
#     class Meta:
# class Alias(models.Model):
#     class Meta:
# class Repository(models.Model):
#     class Meta:
# class Verb(models.Model):
#     class Meta:
# class VerbName(models.Model):
#     class Meta:
# class Property(models.Model):
#     class Meta:
# class Permission(models.Model):
#     class Meta:
# class Access(models.Model):
#     class Meta:
# class Player(models.Model):
#     class Meta:
# class Task(models.Model):
#     class Meta:
#     def __str__(self):
#     def __str__(self):
#     def annotated(self):
#     def name(self):
#     def __str__(self):
#     def __str__(self):
#     def __str__(self):
#     def actor(self):
#     def entity(self):
#     def origin(self):
#     def __str__(self):
#     def __str__(self):
#     def is_authenticated(self):
#     def is_active(self):
#     def is_staff(self):
#     def is_superuser(self):
#     def has_module_perms(self, app):
#     def has_perm(self, perm):
#     def email(self):
# 
# Path: antioch/plugins/editors/tasks.py
# def openeditor(user_id, object_id, type, name):
# def openaccess(user_id, object_id, type, name):
# def modifyobject(user_id, object, name, location, parents, owner):
# def modifyverb(user_id, object_id, verb_id, names, code, ability, method, owner):
# def removeverb(user_id, object_id, verb_name):
# def removeproperty(user_id, object_id, property_name):
# def modifyproperty(user_id, object_id, property_id, name, value, type, owner):
# def modifyaccess(user_id, object_id, type, access):
# def getobjectdetails(user_id, object_id):
# 
# Path: antioch/plugins/editors/forms.py
# class AuthenticatedModelForm(forms.ModelForm):
# class ObjectForm(AuthenticatedModelForm):
#     class Meta:
# class PropertyForm(AuthenticatedModelForm):
#     class Meta:
# class VerbForm(AuthenticatedModelForm):
#     class Meta:
# class AccessForm(forms.ModelForm):
#     class Meta:
#     def __init__(self, user_id=None, *args, **kwargs):
#     def clean_location(self):
#     def clean_owner(self):
#     def clean_parents(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):
#     def clean_owner(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):
#     def clean_owner(self):
#     def _post_clean(self):
#     def save(self, force_insert=False, force_update=False, commit=True):


# Path: antioch/plugins/editors/views.py
import json
from django import template, shortcuts, http
from django.conf import settings
from django.views.generic import UpdateView
from django.utils.decorators import method_decorator
from django.contrib.auth.decorators import login_required
from django.forms.models import modelformset_factory
from antioch.core import models
from antioch.plugins.editors import tasks, forms

class AjaxFormMixin(object):
    def form_valid(self, form):
        try:
            form.save()
            return http.HttpResponse(SUCCESS_JSON, content_type="application/json")
        except Exception as e:
            return http.HttpResponse(EXCEPTION_JSON % e, content_type="application/json", status=500)
    
    def form_invalid(self, form):
        return http.HttpResponse(get_errors_json(form.errors), content_type="application/json", status=422)

class EditorFormView(LoginRequiredMixin, AjaxFormMixin, UpdateView):
    def get_form_kwargs(self):
        kwargs = super(EditorFormView, self).get_form_kwargs()
        kwargs['user_id'] = self.request.user.avatar.id
        return kwargs
    
class ObjectEditorFormView(EditorFormView):
    template_name = 'object-editor.html'
    form_class = forms.ObjectForm
    model = models.Object
    
class PropertyEditorFormView(EditorFormView):
    template_name = 'property-editor.html'
    form_class = forms.PropertyForm
    model = models.Property
    
class VerbEditorFormView(EditorFormView):
    template_name = 'verb-editor.html'
    form_class = forms.VerbForm

    model = models.Verb