Browse Source

Correcting __init__ of Events.

jeremiewcz 1 year ago
parent
commit
a05f900faf
6 changed files with 138 additions and 12 deletions
  1. 1
    1
      app/main/views.py
  2. 11
    0
      app/models/channel.py
  3. 16
    10
      app/models/event.py
  4. 0
    1
      rhino_ynh
  5. 35
    0
      rhino_ynh/conf/nginx.conf
  6. 75
    0
      rhino_ynh/manifest.json

+ 1
- 1
app/main/views.py View File

@@ -162,7 +162,7 @@ def collectives():
162 162
 def collective(coll):
163 163
     """ Return home template for collective coll """
164 164
     channel_id = Channel.query.filter(Channel.name==coll).first()
165
-    podcasts = getPodcasts(filter='Podcast.channel_id=channel_id'),
165
+    podcasts = getPodcasts(filter='Podcast.channel_id==channel_id'),
166 166
     return [ 'displayMain',
167 167
              { "content": render_template("notimplemented.html",
168 168
                                           podcasts=podcasts) }]

+ 11
- 0
app/models/channel.py View File

@@ -63,6 +63,17 @@ class Channel(db.Model):
63 63
         return items
64 64
 
65 65
     @staticmethod
66
+    def init():
67
+        """ Adds generic Channel """
68
+        from sqlalchemy.exc import IntegrityError
69
+        c = Channel(name = "Émission")
70
+        db.session.add(c)
71
+        try:
72
+            db.session.commit()
73
+        except IntegrityError:
74
+            db.session.callback()
75
+
76
+    @staticmethod
66 77
     def fake_feed(count=10):
67 78
         from sqlalchemy.exc import IntegrityError
68 79
         from random import seed, choice

+ 16
- 10
app/models/event.py View File

@@ -2,7 +2,7 @@ from .. import db
2 2
 from datetime import datetime
3 3
 from .podcast import Podcast
4 4
 from .channel import Channel
5
-from sqlalchemy.orm import validates
5
+from sqlalchemy.orm import validates, reconstructor
6 6
 
7 7
 class Event(db.Model):
8 8
     """ An agenda item """
@@ -32,16 +32,18 @@ class Event(db.Model):
32 32
         return self.title
33 33
 
34 34
     def __init__(self, **kwargs):
35
-        if self.live_show == True:
36
-            create_rel_podcast(self)
37
-        super().__init__(**kwargs)
35
+        print(kwargs)
36
+        self.data = kwargs
37
+        if 'live_show' in self.data and self.data['live_show'] == True:
38
+            self.create_rel_podcast(self)
38 39
 
39 40
     @validates('channel_id')
40 41
     def validate_channel_id(self, key, channel_id):
41 42
         if self.live_show == True:
42
-            if not self.channel_id:
43
-                self.channel_id = "Émission"
44
-                return self
43
+            print(self.live_show)
44
+            if not channel_id:
45
+                channel_id = 1
46
+                return channel_id
45 47
             else:
46 48
                 return self
47 49
 
@@ -51,18 +53,22 @@ class Event(db.Model):
51 53
             .paginate(per_page=number).items
52 54
         return events
53 55
 
56
+    # FIXME: Self is not an object and needs to be barsed by its .data[]
57
+    @staticmethod
54 58
     def create_rel_podcast(self):
55
-        channel = Channel.query.filter_by(Channel.id == self.channel_id).first()
59
+        channel = Channel.query.filter(Channel.id == self.channel_id).first()
56 60
         podcast = Podcast(
57 61
             title = channel.title + 'du' + self.date.strftime("%d/%m/%y"),
58 62
             contributors = channel.contributors,
59 63
             desc = self.desc,
60
-            channel_id = self.channel_id,
64
+            channel_id = channel.id,
61 65
             mood = channel.mood,
62 66
             night = channel.night,
67
+            live_show = True,
63 68
             date = self.begin)
64 69
         self.podcast_id = podcast.id
65
-        db.session.add(podcast.id)
70
+        print(podcast)
71
+        db.session.add(podcast)
66 72
         try:
67 73
             db.session.commit()
68 74
         except IntegrityError:

+ 0
- 1
rhino_ynh

@@ -1 +0,0 @@
1
-Subproject commit a0eb745db9f7da594e907a8c5039663fafd49237

+ 35
- 0
rhino_ynh/conf/nginx.conf View File

@@ -0,0 +1,35 @@
1
+location __PATH__ {
2
+
3
+  # Path to source
4
+  alias __FINALPATH__/ ;
5
+
6
+  if ($scheme = http) {
7
+    rewrite ^ https://$server_name$request_uri? permanent;
8
+  }
9
+
10
+  index;
11
+
12
+  # Common parameter to increase upload size limit in conjuction with dedicated php-fpm file
13
+  #client_max_body_size 50M;
14
+
15
+  try_files $uri $uri/;
16
+  location ~ [^/]\(/|$) {
17
+    fastcgi_split_path_info ^(.+?\)(/.*)$;
18
+
19
+    # If you don't use a dedicated fpm config for your app,
20
+    # use a general fpm pool.
21
+    # This is to be used INSTEAD of line above
22
+    # Don't forget to adjust scripts install/upgrade/remove/backup accordingly
23
+    #
24
+    #fastcgi_pass unix:/var/run/php5-fpm.sock;
25
+
26
+    fastcgi_index index;
27
+    include fastcgi_params;
28
+    fastcgi_param REMOTE_USER $remote_user;
29
+    fastcgi_param PATH_INFO $fastcgi_path_info;
30
+    fastcgi_param SCRIPT_FILENAME $request_filename;
31
+  }
32
+
33
+  # Include SSOWAT user panel.
34
+  include conf.d/yunohost_panel.conf.inc;
35
+}

+ 75
- 0
rhino_ynh/manifest.json View File

@@ -0,0 +1,75 @@
1
+{
2
+    "name": "Rhino Radio CMS",
3
+    "id": "rhinoCMS",
4
+    "packaging_format": 1,
5
+    "description": {
6
+        "en": "Experimental webradio CMS.",
7
+        "fr": "CMS de webradio expérimental."
8
+    },
9
+    "version": ".3",
10
+    "url": "https://github.com/hackstub/RhinoRadioCMS",
11
+    "license": "GPL",
12
+    "maintainer": {
13
+        "name": "Hackstub, Radio Rhino",
14
+        "email": "contact@radiorhino.eu",
15
+        "url": "https://radiorhino.eu"
16
+    },
17
+    "requirements": {
18
+        "yunohost": ">= 2.7.2"
19
+    },
20
+    "multi_instance": true,
21
+    "services": [
22
+        "nginx",
23
+        "postgresql"
24
+    ],
25
+    "arguments": {
26
+        "install" : [
27
+            {
28
+                "name": "domain",
29
+                "type": "domain",
30
+                "ask": {
31
+                    "en": "Choose a domain name for Rhino CMS",
32
+                    "fr": "Choisissez un nom de domaine pour Rhino CMS"
33
+                },
34
+                "example": "example.com"
35
+            },
36
+            {
37
+                "name": "path",
38
+                "type": "path",
39
+                "ask": {
40
+                    "en": "Choose a path for Rhino CMS",
41
+                    "fr": "Choisissez un chemin pour Rhino CMS"
42
+                },
43
+                "example": "/example",
44
+                "default": "/rhinocms"
45
+            },
46
+            {
47
+                "name": "admin",
48
+                "type": "user",
49
+                "ask": {
50
+                    "en": "Choose an admin user",
51
+                    "fr": "Choisissez l’administrateur"
52
+                },
53
+                "example": "johndoe"
54
+            },
55
+            {
56
+                "name": "is_public",
57
+                "type": "boolean",
58
+                "ask": {
59
+                    "en": "Is it a public application?",
60
+                    "fr": "Est-ce une application publique ?"
61
+                },
62
+                "default": true
63
+            },
64
+            {
65
+                "name": "language",
66
+                "ask": {
67
+                    "en": "Choose the application language",
68
+                    "fr": "Choisissez la langue de l'application"
69
+                },
70
+                "choices": ["fr", "en"],
71
+                "default": "fr"
72
+            }
73
+        ]
74
+    }
75
+}

Loading…
Cancel
Save