2020-07-10 07:29:16 +00:00
from . import models
from django . forms import ModelForm
2020-08-28 05:14:33 +00:00
from django . forms import TextInput
2020-07-10 07:29:16 +00:00
class AntiSpam ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' combot_anti_spam_use ' ,
' combot_anti_spam_notification ' ,
]
labels = {
' combot_anti_spam_use ' : ' Use Combot Anti-Spam System (CAS) ' ,
' combot_anti_spam_notification ' : ' Send message mentioning that a spammer was banned ' ,
}
help_texts = {
' combot_anti_spam_use ' : ' By doing so, you understand that you will have to comply with their conditions. ' ,
2020-07-10 08:29:16 +00:00
' combot_anti_spam_notification ' : ' Leave it empty to disable. Use {NAME} to display the known spammer \' s name instead; {GROUP} will be replaced for group \' s name. ' ,
2020-07-10 07:29:16 +00:00
}
class CAPTCHA ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' captcha_use ' ,
' captcha_chars ' ,
' captcha_digits ' ,
' captcha_timeout ' ,
' captcha_attempts ' ,
' captcha_first_message ' ,
' captcha_retry_message ' ,
' captcha_leave_mess ' ,
]
2020-07-10 08:29:16 +00:00
labels = {
' captcha_use ' : ' Use CAPTCHA on new members ' ,
' captcha_chars ' : ' Characters that will be used in the CAPTCHA ' ,
' captcha_digits ' : ' Length (in digits) of your CAPTCHA ' ,
' captcha_timeout ' : ' Maximum time (in seconds) to wait for someone to solve the CAPTCHA before kicking ' ,
' captcha_attempts ' : ' Maximum error count before kicking ' ,
' captcha_first_message ' : ' First CAPTCHA message, shown upon arrival ' ,
' captcha_retry_message ' : ' CAPTCHA messages, shown after mistaken attempts ' ,
' captcha_leave_mess ' : ' Do not erase CAPTCHAS and attempts ' ,
}
help_texts = {
' captcha_timeout ' : ' Failed attempts do not reset such timmer ' ,
' captcha_chars ' : ' Make sure all characters are distinct, such as lowercase " L " , uppercase " i " and the number " 1 " , and " oO0 " (2 vowels, 1 number) ' ,
2020-07-11 03:46:39 +00:00
' captcha_first_message ' : ' {NAME} will be replaced for user \' s name; {GROUP} will be replaced for group \' s name; {ATTEMPTS} will be replaced for the number of attempts the user has; {TIMEOUT} will be replaced for amount of seconds an user has to solve the CAPTCHA; up to 1000 characters ' ,
' captcha_retry_message ' : ' {NAME} will be replaced for user \' s name; {GROUP} will be replaced for group \' s name; {ATTEMPTS} will be replaced for the number of remaining attempts the user has; {TIMEOUT} will be replaced for amount of seconds left an user has to solve the CAPTCHA; up to 1000 characters ' ,
2020-07-10 08:29:16 +00:00
' captcha_leave_mess ' : ' Might be spammy if checked ' ,
}
2020-07-10 07:29:16 +00:00
class Greetings ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' join_message ' ,
' leave_message ' ,
]
2020-07-10 08:29:16 +00:00
help_texts = {
' join_message ' : ' Leave blank to disable this feature; {NAME} will be replaced for user \' s name; {GROUP} will be replaced for group \' s name; will be delayed until Anti-Spam and CAPTCHA steps gets either completed or skipped ' ,
' leave_message ' : ' Leave blank to disable this feature; {NAME} will be replaced for user \' s name; {GROUP} will be replaced for group \' s name ' ,
}
2020-07-10 07:29:16 +00:00
class CannedMessage ( ModelForm ) :
class Meta :
model = models . GroupCannedMessage
fields = [ ' listen ' ,
' reply_with ' ,
]
2020-07-10 08:29:16 +00:00
help_texts = {
' listen ' : ' Matches any part in a a larger message ' ,
}
2020-08-28 05:14:33 +00:00
class PlannedMessageTimezone ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' planned_message_timezone ' ,
]
labels = {
' planned_message_timezone ' : ' Timezone ' ,
}
class PlannedMessage ( ModelForm ) :
class Meta :
model = models . GroupPlannedMessage
fields = [ ' tags ' ,
' message ' ,
]
widgets = {
' tags ' : TextInput ( ) ,
}
help_texts = {
' tags ' : ' Comma-sepparated and/or space-sepparated tags '
}
class PlannedDispatch ( ModelForm ) :
class Meta :
model = models . GroupPlannedDispatch
fields = [ ' tags ' ,
' day_sunday ' ,
' day_monday ' ,
' day_tuesday ' ,
' day_wednesday ' ,
' day_thursday ' ,
' day_friday ' ,
' day_saturday ' ,
' time_start ' ,
' time_end ' ,
' time_repeat ' ,
]
widgets = {
' tags ' : TextInput ( ) ,
}
help_texts = {
' tags ' : ' Comma-sepparated or space-sepparated tags '
}
class PlannedMessageConfiguration ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' planned_message_enabled ' ,
' planned_message_issuer ' ,
]
labels = {
' planned_message_enabled ' : ' Is this module enabled? ' ,
' planned_message_issuer ' : ' Which bot will be used? ' ,
}
2020-09-01 21:54:51 +00:00
class AccessControlGrant ( ModelForm ) :
class Meta :
model = models . GroupAccessControlGrant
fields = [ ' allows ' ,
]
labels = {
' allows ' : ' Who else will you grant access to this panel? ' ,
}
class AccessControlUse ( ModelForm ) :
class Meta :
model = models . GroupPreferences
fields = [ ' access_control_use ' ,
]
labels = {
' access_control_use ' : ' Restrict access to bot \' s control panel to group \' s creator and trusted users? ' ,
}
help_texts = {
' access_control_use ' : ' If unchecked, any admin at your group will also be able to manage the bot. ' ,
}