Improve gitlab configuration

Julien LepillerTue Dec 07 03:26:02+0100 2021

ec08cdb

Improve gitlab configuration

offlate/systems/gitlab.py

100100
    def getSystemConfigSpec(data=None):
101101
        specs = []
102102
        specs.extend(GitProject.getSystemConfigSpec())
103-
        specs.append(
103+
        if data is not None:
104+
            instance = urlparse(data['repo']).hostname
105+
            specs.append(
106+
                RowConfigSpec('servers', Project.tr('Gitlab instance configuration'),
107+
                    Project.tr("You need to configure each Gitlab instance \
108+
separately, and you haven't configured the instance at {} yet.".format(instance)),
109+
                    [
110+
                    StringConfigSpec('token', Project.tr('Token'),
111+
                        Project.tr('The token you created from your account. \
112+
You can create it from <a href="#">the Access Tokens tab</a> in your account settings.'),
113+
                        link = '{}/-/profile/personal_access_tokens'.format(instance),
114+
                        placeholder = 'Lynid8y56urst-TdlUs6')
115+
                    ],
116+
                    'server',
117+
                    instance))
118+
        else:
119+
            specs.append(
104120
                ListConfigSpec('servers', Project.tr('Configured Gitlab instances'),
105121
                    Project.tr('You need to create a token for each Gitlab instance \
106122
you have an account on. You can create a token by logging into your account, \

offlate/systems/weblate.py

222222
    @staticmethod
223223
    def getSystemConfigSpec(data=None):
224224
        if data is not None:
225-
            print('weblate: {}'.format(data))
226225
            return [RowConfigSpec('servers', Project.tr('Weblate instance configuration'),
227226
                    Project.tr('You need to configure each Weblate instance separately, \
228227
and you haven\'t configured the instance at {} yet.').format(data['instance']),
229228
                    [
230229
                        StringConfigSpec('token', Project.tr('Token'),
231230
                            Project.tr('The token you created from your account. \
232-
You can create it from <a href="#">The API access tab</a> in your account settings'),
231+
You can create it from <a href="#">the API access tab</a> in your account settings.'),
233232
                            link = "{}/accounts/profile/#api".format(data['instance']),
234233
                            placeholder = Project.tr('fKbStkBgFzIL0UW15sfcJh7kC0BAbcVtV16kblXlM'))
235234
                    ], 'server', data['instance'])]

offlate/ui/settingsedit.py

205205
    def content(self):
206206
        hasRow = False
207207
        for d in self.data:
208-
            print(d)
209208
            if d[self.conf.indexKey] == self.conf.indexValue:
210209
                hasRow = True
211210

offlate/ui/welcome.py

166166
    def initializePage(self):
167167
        layout = QVBoxLayout()
168168
        system = self.field("project")["system"]
169+
        info = self.field("project")["info"]
169170
        lang = self.field("lang")
170171
        email = self.field("email")
171172
        name = self.field("name")
172173
        self.parent.manager.updateSettings({'Generic': {'name': name, 'email': email, 'lang': lang}})
173-
        widget = SystemSettingsWidget(self.parent.manager, system = system, parent = self)
174+
        widget = SystemSettingsWidget(self.parent.manager, system = system, parent = self, data = info)
174175
        layout.addWidget(widget)
175176
        self.setLayout(layout)
176177