Remove unused code

This commit is contained in:
Ramon Wenger 2021-02-22 17:09:47 +01:00
parent e10481ce49
commit 73e3339d81
5 changed files with 3 additions and 61 deletions

File diff suppressed because one or more lines are too long

View File

@ -37,9 +37,3 @@ class ObjectiveAdmin(admin.ModelAdmin):
return topic.title
get_topic.short_description = 'Thema'
@admin.register(ObjectiveProgressStatus)
class ObjectiveProgressStatusAdmin(admin.ModelAdmin):
list_display = ('objective', 'user', 'done')
list_filter = ('objective', 'user', 'done')

View File

@ -46,18 +46,3 @@ class Objective(models.Model):
def __str__(self):
return 'Objective {}-{}'.format(self.id, self.text)
# todo: delete
class ObjectiveProgressStatus(models.Model):
class Meta:
verbose_name = 'Lernzielstatus'
verbose_name_plural = 'Lernzielstatus'
done = models.BooleanField('Lernziel erledigt?', default=False)
objective = models.ForeignKey(Objective, blank=False, null=False, on_delete=models.CASCADE,
related_name='objective_progress')
user = models.ForeignKey(get_user_model(), blank=True, null=True, on_delete=models.CASCADE)
def __str__(self):
return 'Lernzielstatus {}-{}'.format(self.objective, self.done)

View File

@ -6,34 +6,10 @@ from api.utils import get_object
from books.schema.inputs import UserGroupBlockVisibility
from core.utils import set_visible_for, set_hidden_for
from objectives.inputs import AddObjectiveArgument
from objectives.models import ObjectiveProgressStatus, Objective, ObjectiveGroup
from objectives.models import Objective, ObjectiveGroup
from objectives.schema import ObjectiveNode, ObjectiveGroupNode
class UpdateObjectiveProgress(relay.ClientIDMutation):
class Input:
id = graphene.ID(required=True, description="The ID of the objective")
done = graphene.Boolean(required=True)
errors = graphene.List(graphene.String)
objective = graphene.Field(ObjectiveNode)
@classmethod
def mutate_and_get_payload(cls, root, info, **kwargs):
objective_id = kwargs.get('id')
done = kwargs.get('done')
objective = get_object(Objective, objective_id) # info.context.user = django user
objective_progress, created = ObjectiveProgressStatus.objects.get_or_create(
objective=objective,
user=info.context.user
)
objective_progress.done = done
objective_progress.save()
return cls(objective=objective)
class UpdateObjectiveVisibility(relay.ClientIDMutation):
class Input:
id = graphene.ID(required=True, description='The ID of the objective')
@ -124,8 +100,6 @@ class DeleteObjective(relay.ClientIDMutation):
class ObjectiveMutations:
# todo: remove?
update_objective_progress = UpdateObjectiveProgress.Field()
update_objective_visibility = UpdateObjectiveVisibility.Field()
update_objective_group_visibility = UpdateObjectiveGroupVisibility.Field()
add_objective = AddObjective.Field()

View File

@ -4,7 +4,7 @@ from graphene import relay
from graphene_django import DjangoObjectType
from graphene_django.filter import DjangoFilterConnectionField
from objectives.models import ObjectiveGroup, Objective, ObjectiveProgressStatus
from objectives.models import ObjectiveGroup, Objective
class ObjectiveGroupNode(DjangoObjectType):
@ -55,17 +55,6 @@ class ObjectiveNode(DjangoObjectType):
def resolve_mine(self, info, **kwargs):
return self.owner is not None and self.owner.pk == info.context.user.pk
class ObjectiveProgressStatusNode(DjangoObjectType):
pk = graphene.Int()
class Meta:
model = ObjectiveProgressStatus
filter_fields = ['objective__text', 'user__username', 'done']
interfaces = (relay.Node,)
def resolve_pk(self, *args, **kwargs):
return self.id
class ObjectivesQuery(object):
objective_group = relay.Node.Field(ObjectiveGroupNode)