Added description to achievements #268_achievements
This commit is contained in:
@@ -10,6 +10,7 @@ class AchievementFilter(FilterABC):
|
||||
|
||||
self._id = None
|
||||
self._name = None
|
||||
self._description = None
|
||||
self._attribute = None
|
||||
self._operator = None
|
||||
self._value = None
|
||||
@@ -22,6 +23,9 @@ class AchievementFilter(FilterABC):
|
||||
if "name" in values:
|
||||
self._name = values["name"]
|
||||
|
||||
if "description" in values:
|
||||
self._description = values["description"]
|
||||
|
||||
if "attribute" in values:
|
||||
self._attribute = values["attribute"]
|
||||
|
||||
@@ -42,10 +46,13 @@ class AchievementFilter(FilterABC):
|
||||
query = query.where(lambda x: x.id == self._id)
|
||||
|
||||
if self._name is not None:
|
||||
query = query.where(lambda x: x.name == self._name)
|
||||
query = query.where(lambda x: x.name == self._name or self._name in x.name)
|
||||
|
||||
if self._description is not None:
|
||||
query = query.where(lambda x: x.description == self._description or self._description in x.description)
|
||||
|
||||
if self._attribute is not None:
|
||||
query = query.where(lambda x: x.attribute == self._attribute)
|
||||
query = query.where(lambda x: x.attribute == self._attribute or self._attribute in x.attribute)
|
||||
|
||||
if self._operator is not None:
|
||||
query = query.where(lambda x: x.operator == self._operator)
|
||||
|
@@ -9,6 +9,7 @@ type AchievementAttribute {
|
||||
type Achievement implements TableWithHistoryQuery {
|
||||
id: ID
|
||||
name: String
|
||||
description: String
|
||||
attribute: String
|
||||
operator: String
|
||||
value: String
|
||||
@@ -24,6 +25,7 @@ type Achievement implements TableWithHistoryQuery {
|
||||
type AchievementHistory implements HistoryTableQuery {
|
||||
id: ID
|
||||
name: String
|
||||
description: String
|
||||
attribute: String
|
||||
operator: String
|
||||
value: String
|
||||
@@ -38,6 +40,7 @@ type AchievementHistory implements HistoryTableQuery {
|
||||
input AchievementFilter {
|
||||
id: ID
|
||||
name: String
|
||||
description: String
|
||||
attribute: String
|
||||
operator: String
|
||||
value: String
|
||||
@@ -53,6 +56,7 @@ type AchievementMutation {
|
||||
input AchievementInput {
|
||||
id: ID
|
||||
name: String
|
||||
description: String
|
||||
attribute: String
|
||||
operator: String
|
||||
value: String
|
||||
|
@@ -36,6 +36,7 @@ class AchievementMutation(QueryABC):
|
||||
|
||||
achievement = Achievement(
|
||||
input["name"],
|
||||
input["description"],
|
||||
input["attribute"],
|
||||
input["operator"],
|
||||
input["value"],
|
||||
@@ -47,6 +48,7 @@ class AchievementMutation(QueryABC):
|
||||
def get_new_achievement(a: Achievement):
|
||||
return (
|
||||
a.name == achievement.name
|
||||
and a.description == achievement.description
|
||||
and a.attribute == achievement.attribute
|
||||
and a.operator == achievement.operator
|
||||
and a.value == achievement.value
|
||||
@@ -60,6 +62,7 @@ class AchievementMutation(QueryABC):
|
||||
self._can_user_mutate_data(achievement.server, UserRoleEnum.moderator)
|
||||
|
||||
achievement.name = input["name"] if "name" in input else achievement.name
|
||||
achievement.description = input["description"] if "description" in input else achievement.description
|
||||
achievement.attribute = input["attribute"] if "attribute" in input else achievement.attribute
|
||||
achievement.operator = input["operator"] if "operator" in input else achievement.operator
|
||||
achievement.value = input["value"] if "value" in input else achievement.value
|
||||
@@ -74,6 +77,10 @@ class AchievementMutation(QueryABC):
|
||||
achievement = self._achievements.get_achievement_by_id(id)
|
||||
self._can_user_mutate_data(achievement.server, UserRoleEnum.admin)
|
||||
|
||||
joins = self._achievements.get_user_got_achievements_by_achievement_id(id)
|
||||
for join in joins:
|
||||
self._achievements.delete_user_got_achievement(join)
|
||||
|
||||
self._achievements.delete_achievement(achievement)
|
||||
self._db.save_changes()
|
||||
|
||||
|
@@ -7,6 +7,7 @@ class AchievementHistoryQuery(HistoryQueryABC):
|
||||
|
||||
self.set_field("id", lambda x, *_: x.id)
|
||||
self.set_field("name", lambda x, *_: x.name)
|
||||
self.set_field("description", lambda x, *_: x.description)
|
||||
self.set_field("attribute", lambda x, *_: x.attribute)
|
||||
self.set_field("operator", lambda x, *_: x.operator)
|
||||
self.set_field("value", lambda x, *_: x.value)
|
||||
|
@@ -13,6 +13,7 @@ class AchievementQuery(DataQueryWithHistoryABC):
|
||||
|
||||
self.set_field("id", lambda x, *_: x.id)
|
||||
self.set_field("name", lambda x, *_: x.name)
|
||||
self.set_field("description", lambda x, *_: x.description)
|
||||
self.set_field("attribute", lambda x, *_: x.attribute)
|
||||
self.set_field("operator", lambda x, *_: x.operator)
|
||||
self.set_field("value", lambda x, *_: x.value)
|
||||
|
Reference in New Issue
Block a user