mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
few fixes
This commit is contained in:
+2
-3
@@ -3,7 +3,7 @@ version: '3'
|
||||
services:
|
||||
api:
|
||||
container_name: modoboa_api
|
||||
restart: unless-stopped
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.dev
|
||||
@@ -24,13 +24,12 @@ services:
|
||||
|
||||
front:
|
||||
container_name: modoboa_front
|
||||
restart: unless-stopped
|
||||
restart: unless-stopped
|
||||
build:
|
||||
context: .
|
||||
dockerfile: docker/Dockerfile.front.dev
|
||||
ports:
|
||||
- 8080:8080
|
||||
command: ""
|
||||
volumes:
|
||||
- ./frontend/:/home/node/
|
||||
command: "yarn serve"
|
||||
|
||||
@@ -3,8 +3,8 @@ import repository from '@/api/repository'
|
||||
const resource = 'migrations'
|
||||
|
||||
export default {
|
||||
getMigrations (query) {
|
||||
return repository.get(`/${resource}/`, query)
|
||||
getMigrations (params) {
|
||||
return repository.get(`/${resource}/`, { params })
|
||||
},
|
||||
getMigration (slug, query) {
|
||||
return repository.get(`/${resource}/${slug}/`, query)
|
||||
|
||||
@@ -26,13 +26,18 @@
|
||||
:headers="headers"
|
||||
:items="migrations"
|
||||
:search="search"
|
||||
item-key="pk"
|
||||
item-key="id"
|
||||
:options.sync="options"
|
||||
:server-items-length="totalMigrations"
|
||||
:loading="loading"
|
||||
class="elevation-1"
|
||||
show-select
|
||||
>
|
||||
<template v-slot:item.mailbox="{ item }">
|
||||
<router-link :to="{ name: 'AccountDetail', params: { id: item.mailbox.user } }">
|
||||
{{ item.mailbox.full_address }}
|
||||
</router-link>
|
||||
</template>
|
||||
<template v-slot:item.actions="{ item }">
|
||||
<v-menu offset-y>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
@@ -60,9 +65,9 @@ export default {
|
||||
return {
|
||||
migrations: [],
|
||||
headers: [
|
||||
{ text: this.$gettext('Provider'), value: 'provider' },
|
||||
{ text: this.$gettext('Old account'), value: 'old_account' },
|
||||
{ text: this.$gettext('New account'), value: 'new_account' },
|
||||
{ text: this.$gettext('Provider'), value: 'provider.name' },
|
||||
{ text: this.$gettext('Old account'), value: 'username' },
|
||||
{ text: this.$gettext('New account'), value: 'mailbox' },
|
||||
{ text: this.$gettext('Actions'), value: 'actions', sortable: false, align: 'right' }
|
||||
|
||||
],
|
||||
@@ -75,17 +80,10 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
deleteMigration (migration) {
|
||||
this.$dialog.confirm(
|
||||
this.$gettext('Remove this migration?'), {
|
||||
cancelText: this.$gettext('Cancel'),
|
||||
okText: this.$gettext('Proceed')
|
||||
}
|
||||
).then(dialog => {
|
||||
Migration.deleteMigration(migration.id).then(response => {
|
||||
bus.$emit('notification', { msg: this.$gettext('Provider deleted') })
|
||||
this.migrations = this.migrations.filter(item => {
|
||||
return item.id !== migration.id
|
||||
})
|
||||
Migration.deleteMigration(migration.id).then(response => {
|
||||
bus.$emit('notification', { msg: this.$gettext('Migration deleted') })
|
||||
this.migrations = this.migrations.filter(item => {
|
||||
return item.id !== migration.id
|
||||
})
|
||||
})
|
||||
},
|
||||
@@ -97,6 +95,7 @@ export default {
|
||||
}
|
||||
Migration.getMigrations(query).then(response => {
|
||||
this.migrations = response.data
|
||||
this.totalMigrations = this.migrations.length
|
||||
this.loading = false
|
||||
})
|
||||
},
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
<validation-provider
|
||||
v-slot="{ errors }"
|
||||
rules=""
|
||||
vid="initialdomain"
|
||||
vid="name"
|
||||
>
|
||||
<v-text-field
|
||||
ref="initialdomainField"
|
||||
v-model="domain.initialdomain"
|
||||
v-model="domain.name"
|
||||
:error-messages="errors"
|
||||
:placeholder="'Name of the domain to migrate' | translate"
|
||||
outlined
|
||||
@@ -68,7 +68,7 @@ export default {
|
||||
return {
|
||||
domains: [],
|
||||
domain: {
|
||||
initialdomain: '',
|
||||
name: '',
|
||||
new_domain: ''
|
||||
},
|
||||
localDomains: []
|
||||
@@ -78,7 +78,7 @@ export default {
|
||||
reset () {
|
||||
this.domains = []
|
||||
this.domain = {
|
||||
initialdomain: '',
|
||||
name: '',
|
||||
new_domain: ''
|
||||
}
|
||||
},
|
||||
@@ -93,15 +93,15 @@ export default {
|
||||
providerApi.checkAssociatedDomain(this.domain).then(response => {
|
||||
if (response.status === 200) {
|
||||
this.domains.push({
|
||||
name: this.domain.initialdomain,
|
||||
name: this.domain.name,
|
||||
new_domain: this.domain.new_domain
|
||||
})
|
||||
this.$emit('input', this.domains)
|
||||
this.$refs.observer.reset()
|
||||
this.domain = {
|
||||
initialdomain: '',
|
||||
name: '',
|
||||
new_domain: ''
|
||||
}
|
||||
this.$emit('input', this.domains)
|
||||
}
|
||||
}).catch(error => {
|
||||
this.$refs.observer.setErrors(error.response.data)
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
v-model="parameters[param.name]"
|
||||
:label="param.label"
|
||||
:hint="param.help_text"
|
||||
:error="formErrors[param.name] !== undefined"
|
||||
:error-messages="formErrors[param.name]"
|
||||
persistent-hint
|
||||
v-if="param.widget === 'BooleanField'"
|
||||
/>
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { bus } from '@/main'
|
||||
import accounts from '@/api/accounts'
|
||||
import AccountAliases from '@/components/identities/AccountAliases'
|
||||
import AccountSenderAddresses from '@/components/identities/AccountSenderAddresses'
|
||||
@@ -58,6 +59,11 @@ export default {
|
||||
mounted () {
|
||||
accounts.get(this.$route.params.id).then(resp => {
|
||||
this.account = resp.data
|
||||
}).catch(error => {
|
||||
if (error.response.status === 404) {
|
||||
bus.$emit('notification', { msg: this.$gettext('Account not found!'), type: 'error' })
|
||||
this.$router.push({ name: 'Identities' })
|
||||
}
|
||||
})
|
||||
parameters.getApplication('limits').then(resp => {
|
||||
this.limitsConfig = resp.data
|
||||
|
||||
@@ -252,6 +252,18 @@ class AdminGlobalParametersSerializer(serializers.Serializer):
|
||||
)
|
||||
return value
|
||||
|
||||
def validate_auto_create_domain_and_mailbox(self, value):
|
||||
"""
|
||||
Make sure the option does not get deactivated
|
||||
while imap migration is enabled.
|
||||
"""
|
||||
if not value and param_tools.get_global_parameter("enabled_imapmigration",
|
||||
"imap_migration"):
|
||||
raise serializers.ValidationError(
|
||||
_("Please disable imap migration before disabling this option.")
|
||||
)
|
||||
return value
|
||||
|
||||
def validate(self, data):
|
||||
"""Check MX options."""
|
||||
condition = (
|
||||
|
||||
@@ -74,7 +74,7 @@ class MailboxSerializer(serializers.ModelSerializer):
|
||||
"""Simple mailbox serializer."""
|
||||
|
||||
class Meta:
|
||||
fields = ("id", "full_address")
|
||||
fields = ("id", "full_address", "user")
|
||||
model = admin_models.Mailbox
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from rest_framework import serializers
|
||||
from rest_framework.exceptions import ValidationError
|
||||
from modoboa.admin.models import Mailbox
|
||||
from modoboa.imap_migration.api.v1 import serializers as v1_serializers
|
||||
|
||||
from modoboa.admin.models.domain import Domain
|
||||
|
||||
@@ -38,7 +39,7 @@ class CheckProviderSerializer(serializers.Serializer):
|
||||
class CheckAssociatedDomainSerializer(serializers.Serializer):
|
||||
"""A serializer for checking associated domains."""
|
||||
|
||||
initialdomain = serializers.CharField()
|
||||
name = serializers.CharField()
|
||||
new_domain = serializers.PrimaryKeyRelatedField(
|
||||
read_only=True, required=False)
|
||||
|
||||
@@ -50,3 +51,17 @@ class CheckAssociatedDomainSerializer(serializers.Serializer):
|
||||
if value not in domain_ids:
|
||||
raise serializers.ValidationError(_("Access denied"))
|
||||
return value
|
||||
|
||||
|
||||
class MailboxSerializer(serializers.ModelSerializer):
|
||||
"""Simple mailbox serializer."""
|
||||
|
||||
class Meta:
|
||||
fields = ("id", "full_address", "user")
|
||||
model = Mailbox
|
||||
|
||||
|
||||
class MigrationSerializer(v1_serializers.MigrationSerializer):
|
||||
"""Serializer class for Migration."""
|
||||
|
||||
mailbox = MailboxSerializer()
|
||||
|
||||
@@ -2,12 +2,11 @@
|
||||
|
||||
from rest_framework import routers
|
||||
|
||||
from ..v1 import viewsets as v1_viewsets
|
||||
from .viewsets import EmailProviderViewSet
|
||||
from .viewsets import EmailProviderViewSet, MigrationViewSet
|
||||
|
||||
|
||||
router = routers.SimpleRouter()
|
||||
router.register(r"email-providers", EmailProviderViewSet)
|
||||
router.register(r"migrations", v1_viewsets.MigrationViewSet)
|
||||
router.register(r"migrations", MigrationViewSet)
|
||||
|
||||
urlpatterns = router.urls
|
||||
|
||||
@@ -4,11 +4,12 @@ import imaplib
|
||||
import socket
|
||||
import ssl
|
||||
|
||||
from rest_framework import serializers, response
|
||||
from rest_framework import response
|
||||
from rest_framework.decorators import action
|
||||
|
||||
from modoboa.imap_migration.api.v1 import viewsets as v1_viewsets
|
||||
from .serializers import CheckProviderSerializer, CheckAssociatedDomainSerializer
|
||||
|
||||
from . import serializers
|
||||
|
||||
|
||||
class EmailProviderViewSet(v1_viewsets.EmailProviderViewSet):
|
||||
@@ -16,7 +17,7 @@ class EmailProviderViewSet(v1_viewsets.EmailProviderViewSet):
|
||||
@action(methods=["post"], detail=False)
|
||||
def check_connection(self, request, **kwargs):
|
||||
"""check that provided information allow connection to imap server."""
|
||||
serializer = CheckProviderSerializer(data=request.data)
|
||||
serializer = serializers.CheckProviderSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
secured = serializer.data["secured"]
|
||||
address = serializer.data["address"]
|
||||
@@ -39,6 +40,11 @@ class EmailProviderViewSet(v1_viewsets.EmailProviderViewSet):
|
||||
"""check that the associated domain is either the same as the provider,
|
||||
or if a local domain already exists.
|
||||
This is to prevent errros on setup."""
|
||||
serializer = CheckAssociatedDomainSerializer(data=request.data)
|
||||
serializer = serializers.CheckAssociatedDomainSerializer(data=request.data)
|
||||
serializer.is_valid(raise_exception=True)
|
||||
return response.Response(status=200)
|
||||
|
||||
|
||||
class MigrationViewSet(v1_viewsets.MigrationViewSet):
|
||||
""" Change the serializer to add the user id. """
|
||||
serializer_class = serializers.MigrationSerializer
|
||||
|
||||
Reference in New Issue
Block a user