Merge branch 'master' into Production

This commit is contained in:
Martin Pépin 2017-09-25 18:40:00 +02:00
commit b73faa3b84
4 changed files with 27 additions and 19 deletions

View file

@ -1,24 +1,20 @@
services: services:
- mysql:latest - postgres:latest
- redis:latest - redis:latest
variables: variables:
# GestioCOF settings # GestioCOF settings
DJANGO_SETTINGS_MODULE: "cof.settings_dev" DJANGO_SETTINGS_MODULE: "cof.settings.prod"
DBNAME: "cof_gestion" DBHOST: "postgres"
DBUSER: "cof_gestion"
DBPASSWD: "cof_password"
DBHOST: "mysql"
REDIS_HOST: "redis" REDIS_HOST: "redis"
# Cached packages # Cached packages
PYTHONPATH: "$CI_PROJECT_DIR/vendor/python" PYTHONPATH: "$CI_PROJECT_DIR/vendor/python"
# mysql service configuration # postgres service configuration
MYSQL_DATABASE: "$DBNAME" POSTGRES_PASSWORD: "4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4"
MYSQL_USER: "$DBUSER" POSTGRES_USER: "cof_gestion"
MYSQL_PASSWORD: "$DBPASSWD" POSTGRES_DB: "cof_gestion"
MYSQL_ROOT_PASSWORD: "root_password"
cache: cache:
@ -29,13 +25,12 @@ cache:
before_script: before_script:
- mkdir -p vendor/{python,pip,apt} - mkdir -p vendor/{python,pip,apt}
- apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq mysql-client - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" - sed -E 's/^REDIS_HOST.*/REDIS_HOST = "redis"/' cof/settings/secret_example.py > cof/settings/secret.py
-e "GRANT ALL ON test_$DBNAME.* TO '$DBUSER'@'%'"
# Remove the old test database if it has not been done yet # Remove the old test database if it has not been done yet
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host="$DBHOST" - psql --username=cof_gestion --password="4KZt3nGPLVeWSvtBZPSM3fSzXpzEU4" --host="$DBHOST"
-e "DROP DATABASE test_$DBNAME" || true -e "DROP DATABASE test_$DBNAME" || true
- pip install --cache-dir vendor/pip -t vendor/python -r requirements-devel.txt - pip install --cache-dir vendor/pip -t vendor/python -r requirements.txt
test: test:
stage: test stage: test

View file

@ -56,17 +56,17 @@ class AttributionInline(admin.TabularInline):
def get_queryset(self, request): def get_queryset(self, request):
qs = super().get_queryset(request) qs = super().get_queryset(request)
if self.listing is not None: if self.listing is not None:
qs.filter(spectacle__listing=self.listing) qs = qs.filter(spectacle__listing=self.listing)
return qs return qs
class WithListingAttributionInline(AttributionInline): class WithListingAttributionInline(AttributionInline):
exclude = ('given', )
form = WithListingAttributionTabularAdminForm form = WithListingAttributionTabularAdminForm
listing = True listing = True
class WithoutListingAttributionInline(AttributionInline): class WithoutListingAttributionInline(AttributionInline):
exclude = ('given', )
form = WithoutListingAttributionTabularAdminForm form = WithoutListingAttributionTabularAdminForm
listing = False listing = False

View file

@ -21,6 +21,7 @@ ALLOWED_HOSTS = [
STATIC_ROOT = os.path.join( STATIC_ROOT = os.path.join(
os.path.dirname(os.path.dirname(BASE_DIR)), os.path.dirname(os.path.dirname(BASE_DIR)),
"public", "public",
"gestion",
"static", "static",
) )

View file

@ -167,10 +167,22 @@ class GroupForm(forms.ModelForm):
name = self.cleaned_data['name'] name = self.cleaned_data['name']
return 'K-Fêt %s' % name return 'K-Fêt %s' % name
def clean_permissions(self):
kfet_perms = self.cleaned_data['permissions']
# TODO: With Django >=1.11, the QuerySet method 'difference' can be used.
# other_groups = self.instance.permissions.difference(
# self.fields['permissions'].queryset
# )
other_perms = self.instance.permissions.exclude(
pk__in=[p.pk for p in self.fields['permissions'].queryset],
)
return list(kfet_perms) + list(other_perms)
class Meta: class Meta:
model = Group model = Group
fields = ['name', 'permissions'] fields = ['name', 'permissions']
class AccountNegativeForm(forms.ModelForm): class AccountNegativeForm(forms.ModelForm):
class Meta: class Meta:
model = AccountNegative model = AccountNegative