2015-03-25 15:45:04 +00:00
|
|
|
from django import forms
|
2023-11-17 12:25:13 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2015-03-25 15:45:04 +00:00
|
|
|
from rest_framework import serializers
|
|
|
|
|
|
|
|
from orchestra.forms import widgets
|
|
|
|
|
|
|
|
from .. import settings
|
2015-09-21 10:28:49 +00:00
|
|
|
from ..forms import SaaSPasswordForm
|
|
|
|
from .options import SoftwareService
|
2015-03-25 15:45:04 +00:00
|
|
|
|
|
|
|
|
2015-09-21 10:28:49 +00:00
|
|
|
class GitLabForm(SaaSPasswordForm):
|
2015-03-25 15:45:04 +00:00
|
|
|
email = forms.EmailField(label=_("Email"),
|
2015-04-20 14:23:10 +00:00
|
|
|
help_text=_("Initial email address, changes on the GitLab server are not reflected here."))
|
2015-03-25 15:45:04 +00:00
|
|
|
|
|
|
|
|
2015-04-27 12:24:17 +00:00
|
|
|
class GitLaChangeForm(GitLabForm):
|
|
|
|
user_id = forms.IntegerField(label=("User ID"), widget=widgets.SpanWidget,
|
2015-10-09 12:54:30 +00:00
|
|
|
help_text=_("ID of this user used by GitLab, the only attribute that doesn't change."))
|
2015-03-25 15:45:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GitLabSerializer(serializers.Serializer):
|
|
|
|
email = serializers.EmailField(label=_("Email"))
|
2015-10-09 12:54:30 +00:00
|
|
|
user_id = serializers.IntegerField(label=_("User ID"), allow_null=True, required=False)
|
2014-09-26 19:21:09 +00:00
|
|
|
|
2014-09-28 12:28:57 +00:00
|
|
|
|
2014-09-26 19:21:09 +00:00
|
|
|
class GitLabService(SoftwareService):
|
2015-03-25 15:45:04 +00:00
|
|
|
name = 'gitlab'
|
|
|
|
form = GitLabForm
|
2015-04-27 12:24:17 +00:00
|
|
|
change_form = GitLaChangeForm
|
2015-03-25 15:45:04 +00:00
|
|
|
serializer = GitLabSerializer
|
|
|
|
site_domain = settings.SAAS_GITLAB_DOMAIN
|
2016-02-11 14:24:09 +00:00
|
|
|
change_readonly_fields = ('email', 'user_id',)
|
2014-09-26 19:21:09 +00:00
|
|
|
verbose_name = "GitLab"
|
2015-03-04 21:06:16 +00:00
|
|
|
icon = 'orchestra/icons/apps/gitlab.png'
|