# Path: poetry/apps/corpus/models.py
# class MarkupVersion(Model):
#     name = CharField("Имя версии разметки", max_length=50, blank=False)
#     additional = TextField("Дополнительная ифнормация", blank=True)
#     is_manual = BooleanField("Ручные разметки?", default=False)
# 
#     class Meta:
#         verbose_name = "Версия разметки"
#         verbose_name_plural = "Версии разметки"
# 
#     def __str__(self):
#         return str(self.name)
# 
#     def count_markups(self):
#         return self.markups.count()


from django.views.generic.detail import SingleObjectMixin
from django.views.generic import View
from django.http import HttpResponse
from braces.views import LoginRequiredMixin, GroupRequiredMixin
from poetry.apps.corpus.models import MarkupVersion



class MarkupVersionExportView(LoginRequiredMixin, GroupRequiredMixin, SingleObjectMixin, View):
    model = MarkupVersion
    group_required = "Approved"

    def get(self, request, *args, **kwargs):
        version = self.get_object()
        response = HttpResponse()
        content = "["
        for markup in version.markups.all():
            content += markup.text + ","

# Path: poetry/apps/corpus/models.py
# class MarkupVersion(Model):
#     name = CharField("Имя версии разметки", max_length=50, blank=False)
#     additional = TextField("Дополнительная ифнормация", blank=True)
#     is_manual = BooleanField("Ручные разметки?", default=False)
# 
#     class Meta:
#         verbose_name = "Версия разметки"
#         verbose_name_plural = "Версии разметки"
# 
#     def __str__(self):
#         return str(self.name)
# 
#     def count_markups(self):
#         return self.markups.count()


# Path: poetry/apps/corpus/views/version_export_view.py
from django.views.generic.detail import SingleObjectMixin
from django.views.generic import View
from django.http import HttpResponse
from braces.views import LoginRequiredMixin, GroupRequiredMixin
from poetry.apps.corpus.models import MarkupVersion




class MarkupVersionExportView(LoginRequiredMixin, GroupRequiredMixin, SingleObjectMixin, View):
    model = MarkupVersion
    group_required = "Approved"

    def get(self, request, *args, **kwargs):
        version = self.get_object()
        response = HttpResponse()
        content = "["
        for markup in version.markups.all():
            content += markup.text + ","

        content = content[:-1] + "]"