mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-10 20:09:25 +00:00
Graph de famille en frontend (#820)
* Remove graphviz and use cytoscape.js instead * Frontend generated graphs * Make installation easier and faster * Better user experience * Family api and improved interface * Fix url history when using 0, improve button selection and reset reverse with reset button * Use klay layout * Add js translations and apply review comments
This commit is contained in:
committed by
GitHub
parent
bf96d8a10c
commit
f624b7c66d
@ -335,9 +335,40 @@ class UserGodfathersForm(forms.Form):
|
||||
label=_("Add"),
|
||||
)
|
||||
user = AutoCompleteSelectField(
|
||||
"users", required=True, label=_("Select user"), help_text=None
|
||||
"users", required=True, label=_("Select user"), help_text=""
|
||||
)
|
||||
|
||||
def __init__(self, *args, user: User, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.target_user = user
|
||||
|
||||
def clean_user(self):
|
||||
other_user = self.cleaned_data.get("user")
|
||||
if not other_user:
|
||||
raise ValidationError(_("This user does not exist"))
|
||||
if other_user == self.target_user:
|
||||
raise ValidationError(_("You cannot be related to yourself"))
|
||||
return other_user
|
||||
|
||||
def clean(self):
|
||||
super().clean()
|
||||
if not self.is_valid():
|
||||
return self.cleaned_data
|
||||
other_user = self.cleaned_data["user"]
|
||||
if self.cleaned_data["type"] == "godfather":
|
||||
if self.target_user.godfathers.contains(other_user):
|
||||
self.add_error(
|
||||
"user",
|
||||
_("%s is already your godfather") % (other_user.get_short_name()),
|
||||
)
|
||||
else:
|
||||
if self.target_user.godchildren.contains(other_user):
|
||||
self.add_error(
|
||||
"user",
|
||||
_("%s is already your godchild") % (other_user.get_short_name()),
|
||||
)
|
||||
return self.cleaned_data
|
||||
|
||||
|
||||
class PagePropForm(forms.ModelForm):
|
||||
error_css_class = "error"
|
||||
|
Reference in New Issue
Block a user